Make flags none siegeable.

This commit is contained in:
Coder12a 2018-03-27 14:56:01 -07:00
parent 8f1c10a595
commit 62e6c019fe
2 changed files with 17 additions and 10 deletions

View File

@ -1,3 +1,4 @@
ctf_protect
ctf
ctf_flag
chatplus?

View File

@ -1,4 +1,8 @@
material_Strengths = {}
black_list = {"ctf_flag:flag","ctf_flag:flag_captured_top"}
for color, _ in pairs(ctf.flag_colors) do
table.insert(black_list,"ctf_flag:flag_top_"..color)
end
siegehammer_Damage = 1
minetest.register_chatcommand("node_strength", {
@ -97,6 +101,12 @@ minetest.register_tool("siege_hammer:siege_hammer", {
local name = user:get_player_name()
local team = ctf.get_territory_owner(pos)
local p_team = ctf.player(name).team
for i in pairs(black_list) do
if black_list[i] == node.name then
minetest.chat_send_player(name, "None siegeable block.")
return itemstack
end
end
if not team then
minetest.chat_send_player(name, "This only works in protected areas.")
return itemstack
@ -139,19 +149,15 @@ minetest.register_tool("siege_hammer:siege_hammer", {
if meta then
local tmp = meta:to_table()
if tmp then
if tmp.fields then
if not tmp.fields.siege_health then
tmp.fields.siege_health = material_Strengths[realNode.name]
end
-- Damage code.
if tmp.fields.siege_health then
tmp.fields.siege_health = tmp.fields.siege_health - damage_number
health = tmp.fields.siege_health
meta:from_table(tmp)
end
end
end
end
if health <= 0 then
local drops = minetest.get_node_drops(minetest.get_node(pos).name, "siege_hammer:siege_hammer")
minetest.remove_node(pos)