Fix class change on captured flag not working
This commit is contained in:
parent
63b543a8fb
commit
917e362d39
2 changed files with 24 additions and 36 deletions
|
@ -153,25 +153,12 @@ ctf_colors.set_skin = function(player, color)
|
||||||
ctf_classes.set_skin(player, color, ctf_classes.get(player))
|
ctf_classes.set_skin(player, color, ctf_classes.get(player))
|
||||||
end
|
end
|
||||||
|
|
||||||
local flags = {
|
local old_func = ctf_flag.on_punch
|
||||||
"ctf_flag:flag",
|
|
||||||
"ctf_flag:flag_top_red",
|
|
||||||
"ctf_flag:flag_top_blue",
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, flagname in pairs(flags) do
|
|
||||||
local old_func = minetest.registered_nodes[flagname].on_punch
|
|
||||||
local function on_punch(pos, node, player, ...)
|
local function on_punch(pos, node, player, ...)
|
||||||
local fpos = pos
|
|
||||||
if node.name:sub(1, 18) == "ctf_flag:flag_top_" then
|
|
||||||
fpos = vector.new(pos)
|
|
||||||
fpos.y = fpos.y - 1
|
|
||||||
end
|
|
||||||
|
|
||||||
local class = ctf_classes.get(player)
|
local class = ctf_classes.get(player)
|
||||||
if not class.properties.can_capture then
|
if not class.properties.can_capture then
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
local flag = ctf_flag.get(fpos)
|
local flag = ctf_flag.get(pos)
|
||||||
local team = ctf.player(pname).team
|
local team = ctf.player(pname).team
|
||||||
if flag and flag.team and team and team ~= flag.team then
|
if flag and flag.team and team and team ~= flag.team then
|
||||||
minetest.chat_send_player(pname,
|
minetest.chat_send_player(pname,
|
||||||
|
@ -182,14 +169,13 @@ for _, flagname in pairs(flags) do
|
||||||
|
|
||||||
return old_func(pos, node, player, ...)
|
return old_func(pos, node, player, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function show(_, _, player)
|
local function show(_, _, player)
|
||||||
ctf_classes.show_gui(player:get_player_name(), player)
|
ctf_classes.show_gui(player:get_player_name(), player)
|
||||||
end
|
end
|
||||||
minetest.override_item(flagname, {
|
|
||||||
on_punch = on_punch,
|
ctf_flag.on_rightclick = show
|
||||||
on_rightclick = show,
|
ctf_flag.on_punch = on_punch
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
ctf_classes.register_on_changed(function(player, old, new)
|
ctf_classes.register_on_changed(function(player, old, new)
|
||||||
if not old then
|
if not old then
|
||||||
|
|
|
@ -20,8 +20,10 @@ minetest.register_node("ctf_flag:flag", {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
groups = {immortal=1,is_flag=1,flag_bottom=1},
|
groups = {immortal=1,is_flag=1,flag_bottom=1},
|
||||||
on_punch = ctf_flag.on_punch,
|
|
||||||
on_rightclick = ctf_flag.on_rightclick,
|
-- Wrap fuctions to allow overriding
|
||||||
|
on_punch = function(...) ctf_flag.on_punch(...) end,
|
||||||
|
on_rightclick = function(...) ctf_flag.on_rightclick(...) end,
|
||||||
on_construct = ctf_flag.on_construct,
|
on_construct = ctf_flag.on_construct,
|
||||||
after_place_node = ctf_flag.after_place_node,
|
after_place_node = ctf_flag.after_place_node,
|
||||||
on_timer = ctf_flag.flag_tick
|
on_timer = ctf_flag.flag_tick
|
||||||
|
|
Loading…
Reference in a new issue