Skip to content

Commit

Permalink
Edge case: wool naming
Browse files Browse the repository at this point in the history
  • Loading branch information
s20 committed Dec 10, 2023
1 parent eb42760 commit f838e9b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions mods/ctf/ctf_map/nodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,13 @@ minetest.register_chatcommand("indestructify", {
local str = node.name:match("%S+:(%S+)")

if not node.name:match("ctf_map:") and str then
node.name = "ctf_map:" .. str
-- Edge case: wool:red -> ctf_map:wool_red
if node.name:match("wool:") then
local wool_color = node.name:match("wool:(%S+)")
node.name = "ctf_map:wool_" .. wool_color
else
node.name = "ctf_map:" .. str
end
if minetest.registered_nodes[node.name] then
minetest.swap_node(pos, node)
end
Expand Down Expand Up @@ -298,10 +304,16 @@ minetest.register_chatcommand("destructify", {
local str = node.name:match("%S+:(%S+)")

if node.name:match("ctf_map:") and str then
-- Edge case: ctf_map:wool_red -> wool:red
local target_node_name
for _, rnode in pairs(minetest.registered_nodes) do
if rnode.name:match(":" .. str .. "$") and not rnode.name:match("ctf_map:") then
target_node_name = rnode.name
if node.name:match("ctf_map:wool") then
local wool_color = node.name:match("ctf_map:wool_(%S+)")
target_node_name = "wool:" .. wool_color
else
for _, rnode in pairs(minetest.registered_nodes) do
if rnode.name:match(":" .. str .. "$") and not rnode.name:match("ctf_map:") then
target_node_name = rnode.name
end
end
end
if target_node_name then
Expand All @@ -319,4 +331,3 @@ minetest.register_chatcommand("destructify", {
end)
end,
})

0 comments on commit f838e9b

Please sign in to comment.