D00Med b7290a0931 D00Med update 3/9/17
>added village book
>village book and crafting guide are given to players when they join.
>changed oak tree schematics
>added cannon (temp.)
2017-09-03 10:32:04 +10:00

45 lines
1.1 KiB
Lua

local stuff_string = minetest.setting_get("initial_stuff") or
"default:pick_steel,default:axe_steel,default:shovel_steel," ..
"default:torch 99,default:cobble 99"
give_initial_stuff = {
items = {"craftguide:book", "villages:book"}
}
function give_initial_stuff.give(player)
minetest.log("action",
"Giving initial stuff to player " .. player:get_player_name())
local inv = player:get_inventory()
for _, stack in ipairs(give_initial_stuff.items) do
inv:add_item("main", stack)
end
end
function give_initial_stuff.add(stack)
give_initial_stuff.items[#give_initial_stuff.items + 1] = ItemStack(stack)
end
function give_initial_stuff.clear()
give_initial_stuff.items = {}
end
function give_initial_stuff.add_from_csv(str)
local items = str:split(",")
for _, itemname in ipairs(items) do
give_initial_stuff.add(itemname)
end
end
function give_initial_stuff.set_list(list)
give_initial_stuff.items = list
end
function give_initial_stuff.get_list()
return give_initial_stuff.items
end
give_initial_stuff.add_from_csv(stuff_string)
if minetest.setting_getbool("give_initial_stuff") then
minetest.register_on_newplayer(give_initial_stuff.give)
end