aboutsummaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2017-05-10 15:29:21 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-05-10 15:29:21 +0200
commit071e114ffa945522a7a9acc3259427166992d5ee (patch)
treeb76be5cdc27e9a8d9b58ff15f80691e012afa702 /games
parent6945f807abd789e0f522351e5e790ff2afced233 (diff)
downloadminetest-071e114ffa945522a7a9acc3259427166992d5ee.tar.gz
minetest-071e114ffa945522a7a9acc3259427166992d5ee.tar.bz2
minetest-071e114ffa945522a7a9acc3259427166992d5ee.zip
Private nodemeta (#5702)
* Private node metadata that isn't sent to the client
Diffstat (limited to 'games')
-rw-r--r--games/minimal/mods/default/init.lua2
-rw-r--r--games/minimal/mods/experimental/init.lua10
2 files changed, 10 insertions, 2 deletions
diff --git a/games/minimal/mods/default/init.lua b/games/minimal/mods/default/init.lua
index 64970f922..7d26f38a0 100644
--- a/games/minimal/mods/default/init.lua
+++ b/games/minimal/mods/default/init.lua
@@ -1228,6 +1228,8 @@ minetest.register_node("default:chest_locked", {
meta:set_string("owner", "")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
+ -- this is not really the intended usage but works for testing purposes:
+ meta:mark_as_private("owner")
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
diff --git a/games/minimal/mods/experimental/init.lua b/games/minimal/mods/experimental/init.lua
index 5e98e1a80..6e0fb1738 100644
--- a/games/minimal/mods/experimental/init.lua
+++ b/games/minimal/mods/experimental/init.lua
@@ -502,10 +502,16 @@ minetest.register_craftitem("experimental:tester_tool_1", {
on_use = function(itemstack, user, pointed_thing)
--print(dump(pointed_thing))
if pointed_thing.type == "node" then
- if minetest.get_node(pointed_thing.under).name == "experimental:tester_node_1" then
+ local node = minetest.get_node(pointed_thing.under)
+ if node.name == "experimental:tester_node_1" or node.name == "default:chest" then
local p = pointed_thing.under
minetest.log("action", "Tester tool used at "..minetest.pos_to_string(p))
- minetest.dig_node(p)
+ if node.name == "experimental:tester_node_1" then
+ minetest.dig_node(p)
+ else
+ minetest.get_meta(p):mark_as_private({"infotext", "formspec"})
+ minetest.chat_send_player(user:get_player_name(), "Verify that chest is unusable now.")
+ end
else
local p = pointed_thing.above
minetest.log("action", "Tester tool used at "..minetest.pos_to_string(p))