1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-12-23 07:10:19 +01:00
minetest_game/mods/give_initial_stuff/init.lua

47 lines
1.1 KiB
Lua
Raw Normal View History

-- gave_initial_stuff/init.lua
2017-05-22 15:41:17 +02:00
local stuff_string = minetest.settings:get("initial_stuff") or
2016-01-02 13:28:07 +01:00
"default:pick_steel,default:axe_steel,default:shovel_steel," ..
"default:torch 99,default:cobble 99"
give_initial_stuff = {
items = {}
}
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)
2012-03-26 21:50:35 +02:00
end
2016-01-02 13:28:07 +01:00
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
2012-03-26 21:50:35 +02:00
2016-01-02 13:28:07 +01:00
give_initial_stuff.add_from_csv(stuff_string)
2017-05-22 15:41:17 +02:00
if minetest.settings:get_bool("give_initial_stuff") then
2016-01-02 13:28:07 +01:00
minetest.register_on_newplayer(give_initial_stuff.give)
end