Add per-map initial stuff
This commit is contained in:
parent
d2db81bf9b
commit
749bde3165
6 changed files with 34 additions and 27 deletions
|
@ -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)
|
|
|
@ -41,5 +41,3 @@ sfinv.register_page("ctf_inventory:help", {
|
||||||
return sfinv.make_formspec(player, context, fs, false)
|
return sfinv.make_formspec(player, context, fs, false)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
dofile(minetest.get_modpath("ctf_inventory") .. "/give_initial_stuff.lua")
|
|
||||||
|
|
22
mods/ctf_map/give_initial_stuff.lua
Normal file
22
mods/ctf_map/give_initial_stuff.lua
Normal file
|
@ -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)
|
|
@ -7,6 +7,7 @@ dofile(minetest.get_modpath("ctf_map") .. "/barrier.lua")
|
||||||
|
|
||||||
if minetest.get_modpath("ctf") then
|
if minetest.get_modpath("ctf") then
|
||||||
dofile(minetest.get_modpath("ctf_map") .. "/schem_map.lua")
|
dofile(minetest.get_modpath("ctf_map") .. "/schem_map.lua")
|
||||||
|
dofile(minetest.get_modpath("ctf_map") .. "/give_initial_stuff.lua")
|
||||||
|
|
||||||
assert(ctf_match)
|
assert(ctf_match)
|
||||||
ctf_match.register_on_build_time_end(ctf_map.remove_middle_barrier)
|
ctf_match.register_on_build_time_end(ctf_map.remove_middle_barrier)
|
||||||
|
|
|
@ -3,6 +3,7 @@ author = rubenwardy
|
||||||
rotation = z
|
rotation = z
|
||||||
r = 115
|
r = 115
|
||||||
h = 230
|
h = 230
|
||||||
|
initial_stuff = default:pick_steel,default:sword_wood,default:torch 20
|
||||||
team.1 = red
|
team.1 = red
|
||||||
team.1.color = red
|
team.1.color = red
|
||||||
team.1.pos = -20,-2,65
|
team.1.pos = -20,-2,65
|
||||||
|
|
|
@ -48,15 +48,17 @@ function ctf_match.load_map_meta(idx, name)
|
||||||
local offset = vector.new(600 * (idx - 1), 0, 0)
|
local offset = vector.new(600 * (idx - 1), 0, 0)
|
||||||
local meta = Settings(mapdir .. name .. ".conf")
|
local meta = Settings(mapdir .. name .. ".conf")
|
||||||
|
|
||||||
|
local initial_stuff = meta:get("initial_stuff")
|
||||||
local map = {
|
local map = {
|
||||||
idx = idx,
|
idx = idx,
|
||||||
name = meta:get("name"),
|
name = meta:get("name"),
|
||||||
author = meta:get("author"),
|
author = meta:get("author"),
|
||||||
rotation = meta:get("rotation"),
|
rotation = meta:get("rotation"),
|
||||||
schematic = name .. ".mts",
|
schematic = name .. ".mts",
|
||||||
r = tonumber(meta:get("r")),
|
r = tonumber(meta:get("r")),
|
||||||
h = tonumber(meta:get("h")),
|
h = tonumber(meta:get("h")),
|
||||||
teams = {}
|
teams = {},
|
||||||
|
initial_stuff = initial_stuff and initial_stuff:split(","),
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(map.r <= max_r)
|
assert(map.r <= max_r)
|
||||||
|
|
Loading…
Reference in a new issue