forked from VoxeLibre/VoxeLibre
Starting Inventory fix #2
This commit is contained in:
parent
c57a757510
commit
181628e539
|
@ -3,20 +3,18 @@
|
||||||
---
|
---
|
||||||
--- Copyright notice created for the license to be valid. (MIT 3)
|
--- Copyright notice created for the license to be valid. (MIT 3)
|
||||||
|
|
||||||
|
local DEBUG = true
|
||||||
|
|
||||||
local give_inventory = minetest.settings:get("starting_inv_contents", false)
|
local give_inventory = minetest.settings:get("starting_inv_contents", false)
|
||||||
|
|
||||||
local stuff_string
|
local stuff_string
|
||||||
if give_inventory then
|
|
||||||
stuff_string = "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron,mcl_torches:torch 32,mcl_core:cobble 32"
|
|
||||||
end
|
|
||||||
|
|
||||||
mcl_starting_inventory = {
|
mcl_starting_inventory = {
|
||||||
items = {}
|
items = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mcl_starting_inventory.give(player)
|
function mcl_starting_inventory.give(player)
|
||||||
minetest.log("action",
|
mcl_log("Giving initial stuff to player " .. player:get_player_name())
|
||||||
"Giving initial stuff to player " .. player:get_player_name())
|
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
for _, stack in ipairs(mcl_starting_inventory.items) do
|
for _, stack in ipairs(mcl_starting_inventory.items) do
|
||||||
inv:add_item("main", stack)
|
inv:add_item("main", stack)
|
||||||
|
@ -46,7 +44,17 @@ function mcl_starting_inventory.get_list()
|
||||||
return mcl_starting_inventory.items
|
return mcl_starting_inventory.items
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_starting_inventory.add_from_csv(stuff_string)
|
local function mcl_log(message)
|
||||||
if minetest.settings:get_bool("mcl_starting_inventory") then
|
if DEBUG then
|
||||||
minetest.register_on_newplayer(mcl_starting_inventory.give)
|
minetest.log(message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if give_inventory then
|
||||||
|
stuff_string = "mcl_tools:pick_iron,mcl_tools:axe_iron,mcl_tools:shovel_iron,mcl_torches:torch 32,mcl_core:cobble 32"
|
||||||
|
mcl_starting_inventory.add_from_csv(stuff_string)
|
||||||
|
mcl_log("okay to give inventory: " .. stuff_string)
|
||||||
|
if minetest.settings:get_bool("mcl_starting_inventory") then
|
||||||
|
minetest.register_on_newplayer(mcl_starting_inventory.give)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue