Skip to content

Commit

Permalink
Make Reinforced Cobblestone harder to break for the enemy team (#1250)
Browse files Browse the repository at this point in the history
* Make Reinforced Cobblestone harder to break for enemy team

* Keep meta data if node is replaced.

* Oops, remove extra line

* fix luacheck warning

* Forgot to remove this
  • Loading branch information
a-blob authored Dec 5, 2023
1 parent 296ad48 commit b66c0d6
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions mods/ctf/ctf_map/ctf_traps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,49 @@ minetest.register_node("ctf_map:reinforced_cobble", {
description = "Reinforced Cobblestone",
tiles = {"ctf_map_reinforced_cobble.png"},
is_ground_content = false,
groups = {cracky = 3, stone = 2},
sounds = default.node_sound_stone_defaults(),
on_punch = function(pos, node, digger)
local meta = minetest.get_meta(pos)
local placer_team = meta:get_string("placer_team")
local digger_team = ctf_teams.get(digger)
if placer_team ~= digger_team then
minetest.set_node(pos, {name = "ctf_map:reinforced_cobble_hardened"})
meta = minetest.get_meta(pos)
meta:set_string("placer_team", placer_team)
end
end,
after_place_node = function(pos, placer, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
meta:set_string("placer_team", ctf_teams.get(placer))
end,
on_dig = function(pos, node, digger)
local meta = minetest.get_meta(pos)
meta:set_string("placer_team", "")
minetest.node_dig(pos, node, digger)
end
})

minetest.register_node("ctf_map:reinforced_cobble_hardened", {
description = "Reinforced Cobblestone Hardened\nYou're not meant to use this",
tiles = {"ctf_map_reinforced_cobble.png"},
is_ground_content = false,
groups = {cracky = 1, stone = 2},
sounds = default.node_sound_stone_defaults(),
drop = "ctf_map:reinforced_cobble",
on_punch = function(pos, node, digger)
local meta = minetest.get_meta(pos)
local placer_team = meta:get_string("placer_team")
local digger_team = ctf_teams.get(digger)
if placer_team == digger_team then
minetest.set_node(pos, {name = "ctf_map:reinforced_cobble"})
meta = minetest.get_meta(pos)
meta:set_string("placer_team", placer_team)
end
end,
on_dig = function(pos, node, digger)
local meta = minetest.get_meta(pos)
meta:set_string("placer_team", "")
minetest.node_dig(pos, node, digger)
end
})

0 comments on commit b66c0d6

Please sign in to comment.