2024-10-28 15:57:54 +01:00
|
|
|
core.register_tool("testtools:privatizer", {
|
2022-10-09 14:20:35 +02:00
|
|
|
description = "Node Meta Privatizer".."\n"..
|
|
|
|
"Punch: Marks 'infotext' and 'formspec' meta fields of chest as private",
|
|
|
|
inventory_image = "testtools_privatizer.png",
|
|
|
|
groups = { testtool = 1, disable_repair = 1 },
|
|
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
|
|
if pointed_thing.type == "node" then
|
2024-10-28 15:57:54 +01:00
|
|
|
local node = core.get_node(pointed_thing.under)
|
|
|
|
if core.get_item_group(node.name, "meta_is_privatizable") == 1 then
|
2022-10-09 14:20:35 +02:00
|
|
|
local p = pointed_thing.under
|
2024-10-28 15:57:54 +01:00
|
|
|
core.log("action", "[testtools] Privatizer used at "..core.pos_to_string(p))
|
|
|
|
core.get_meta(p):mark_as_private({"infotext", "formspec"})
|
2022-10-09 14:20:35 +02:00
|
|
|
if user and user:is_player() then
|
2024-10-28 15:57:54 +01:00
|
|
|
core.chat_send_player(user:get_player_name(), "Node metadata (infotext, formspec) set private!")
|
2022-10-08 20:01:59 +02:00
|
|
|
end
|
|
|
|
return
|
|
|
|
elseif node.name == "chest_of_everything:chest" then
|
|
|
|
if user and user:is_player() then
|
2024-10-28 15:57:54 +01:00
|
|
|
core.chat_send_player(user:get_player_name(), "Privatizer can't be used on the Chest of Everything. Use it on a normal chest.")
|
2022-10-09 14:20:35 +02:00
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if user and user:is_player() then
|
2024-10-28 15:57:54 +01:00
|
|
|
core.chat_send_player(user:get_player_name(), "Privatizer can only be used on chest!")
|
2022-10-09 14:20:35 +02:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|