diff --git a/mods/ctf_inventory/give_initial_stuff.lua b/mods/ctf_inventory/give_initial_stuff.lua deleted file mode 100644 index 87b2309..0000000 --- a/mods/ctf_inventory/give_initial_stuff.lua +++ /dev/null @@ -1,17 +0,0 @@ -function give_initial_stuff(player) - if minetest.setting_getbool("give_initial_stuff") then - minetest.log("action", "Giving initial stuff to player "..player:get_player_name()) - local inv = player:get_inventory() - inv:set_list("main", {}) - inv:set_list("craft", {}) - inv:add_item('main', 'default:pick_wood') - inv:add_item('main', 'default:sword_wood') - inv:add_item('main', 'default:torch 3') - end -end - -minetest.register_on_joinplayer(function(player) - player:set_hp(20) - give_initial_stuff(player) -end) -minetest.register_on_respawnplayer(give_initial_stuff) diff --git a/mods/ctf_inventory/init.lua b/mods/ctf_inventory/init.lua index 57f0721..d776168 100644 --- a/mods/ctf_inventory/init.lua +++ b/mods/ctf_inventory/init.lua @@ -41,5 +41,3 @@ sfinv.register_page("ctf_inventory:help", { return sfinv.make_formspec(player, context, fs, false) end }) - -dofile(minetest.get_modpath("ctf_inventory") .. "/give_initial_stuff.lua") diff --git a/mods/ctf_map/give_initial_stuff.lua b/mods/ctf_map/give_initial_stuff.lua new file mode 100644 index 0000000..c8d9a21 --- /dev/null +++ b/mods/ctf_map/give_initial_stuff.lua @@ -0,0 +1,22 @@ +function give_initial_stuff(player) + minetest.log("action", "Giving initial stuff to player "..player:get_player_name()) + local inv = player:get_inventory() + inv:set_list("main", {}) + inv:set_list("craft", {}) + + local items = ctf_map.map and ctf_map.map.initial_stuff or { + "default:pick_wood", + "default:sword_wood", + "default:torch 3", + } + + for _, item in pairs(items) do + inv:add_item("main", item) + end +end + +minetest.register_on_joinplayer(function(player) + player:set_hp(20) + give_initial_stuff(player) +end) +minetest.register_on_respawnplayer(give_initial_stuff) diff --git a/mods/ctf_map/init.lua b/mods/ctf_map/init.lua index c1f03fe..e264cf6 100644 --- a/mods/ctf_map/init.lua +++ b/mods/ctf_map/init.lua @@ -7,6 +7,7 @@ dofile(minetest.get_modpath("ctf_map") .. "/barrier.lua") if minetest.get_modpath("ctf") then dofile(minetest.get_modpath("ctf_map") .. "/schem_map.lua") + dofile(minetest.get_modpath("ctf_map") .. "/give_initial_stuff.lua") assert(ctf_match) ctf_match.register_on_build_time_end(ctf_map.remove_middle_barrier) diff --git a/mods/ctf_map/maps/03_caverns.conf b/mods/ctf_map/maps/03_caverns.conf index c18eef9..ecb4279 100644 --- a/mods/ctf_map/maps/03_caverns.conf +++ b/mods/ctf_map/maps/03_caverns.conf @@ -3,6 +3,7 @@ author = rubenwardy rotation = z r = 115 h = 230 +initial_stuff = default:pick_steel,default:sword_wood,default:torch 20 team.1 = red team.1.color = red team.1.pos = -20,-2,65 diff --git a/mods/ctf_map/schem_map.lua b/mods/ctf_map/schem_map.lua index e73f95e..2113d2a 100644 --- a/mods/ctf_map/schem_map.lua +++ b/mods/ctf_map/schem_map.lua @@ -48,15 +48,17 @@ function ctf_match.load_map_meta(idx, name) local offset = vector.new(600 * (idx - 1), 0, 0) local meta = Settings(mapdir .. name .. ".conf") + local initial_stuff = meta:get("initial_stuff") local map = { - idx = idx, - name = meta:get("name"), - author = meta:get("author"), - rotation = meta:get("rotation"), - schematic = name .. ".mts", - r = tonumber(meta:get("r")), - h = tonumber(meta:get("h")), - teams = {} + idx = idx, + name = meta:get("name"), + author = meta:get("author"), + rotation = meta:get("rotation"), + schematic = name .. ".mts", + r = tonumber(meta:get("r")), + h = tonumber(meta:get("h")), + teams = {}, + initial_stuff = initial_stuff and initial_stuff:split(","), } assert(map.r <= max_r)