diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2016-04-01 20:02:19 -0400 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2016-04-01 21:09:33 -0400 |
commit | da66780a569712c23ae4f2996cfb4608a9f9d69d (patch) | |
tree | 217556029a78bc23ad4564720afc86de97228a04 /currency/safe.lua | |
parent | 615b22df4d423aded3613db7716943a2f389b047 (diff) | |
download | dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.gz dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.bz2 dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.xz dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.zip |
copy all standard Dreambuilder mods in from the old subgame
(exactly as last supplied there, updates to these mods will follow later)
Diffstat (limited to 'currency/safe.lua')
-rw-r--r-- | currency/safe.lua | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/currency/safe.lua b/currency/safe.lua new file mode 100644 index 0000000..428711f --- /dev/null +++ b/currency/safe.lua @@ -0,0 +1,103 @@ +function default.get_safe_formspec(pos)
+ local spos = pos.x .. "," .. pos.y .. "," ..pos.z
+ local formspec =
+ "size[8,9]"..
+ "list[nodemeta:".. spos .. ";main;1,1;6,2;]"..
+ "list[current_player;main;0,5;8,4;]"
+ return formspec
+end
+
+local function has_safe_privilege(meta, player)
+ if not player or player:get_player_name() ~= meta:get_string("owner") then
+ return false
+ end
+ return true
+end
+
+minetest.register_node("currency:safe", {
+ description = "Safe",
+ inventory_image = "safe_front.png",
+ paramtype = "light",
+ paramtype2 = "facedir",
+ tiles = {"safe_side.png",
+ "safe_side.png",
+ "safe_side.png",
+ "safe_side.png",
+ "safe_side.png",
+ "safe_front.png",},
+ is_ground_content = false,
+ groups = {cracky=1},
+ after_place_node = function(pos, placer)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("owner", placer:get_player_name() or "")
+ meta:set_string("infotext", "Safe (owned by "..
+ meta:get_string("owner")..")")
+ end,
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("infotext", "Safe")
+ meta:set_string("owner", "")
+ local inv = meta:get_inventory()
+ inv:set_size("main", 6*2)
+ end,
+ can_dig = function(pos,player)
+ local meta = minetest.get_meta(pos);
+ local inv = meta:get_inventory()
+ return inv:is_empty("main") and has_safe_privilege(meta, player)
+ end,
+ allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+ local meta = minetest.get_meta(pos)
+ if not has_safe_privilege(meta, player) then
+ minetest.log("action", player:get_player_name()..
+ " tried to access a safe belonging to "..
+ meta:get_string("owner").." at "..
+ minetest.pos_to_string(pos))
+ return 0
+ end
+ return count
+ end,
+ allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+ local meta = minetest.get_meta(pos)
+ if not has_safe_privilege(meta, player) then
+ minetest.log("action", player:get_player_name()..
+ " tried to access a safe belonging to "..
+ meta:get_string("owner").." at "..
+ minetest.pos_to_string(pos))
+ return 0
+ end
+ return stack:get_count()
+ end,
+ allow_metadata_inventory_take = function(pos, listname, index, stack, player)
+ local meta = minetest.get_meta(pos)
+ if not has_safe_privilege(meta, player) then
+ minetest.log("action", player:get_player_name()..
+ " tried to access a safe belonging to "..
+ meta:get_string("owner").." at "..
+ minetest.pos_to_string(pos))
+ return 0
+ end
+ return stack:get_count()
+ end,
+ on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+ minetest.log("action", player:get_player_name()..
+ " moves stuff in safe at "..minetest.pos_to_string(pos))
+ end,
+ on_metadata_inventory_put = function(pos, listname, index, stack, player)
+ minetest.log("action", player:get_player_name()..
+ " moves stuff to safe at "..minetest.pos_to_string(pos))
+ end,
+ on_metadata_inventory_take = function(pos, listname, index, stack, player)
+ minetest.log("action", player:get_player_name()..
+ " takes stuff from safe at "..minetest.pos_to_string(pos))
+ end,
+ on_rightclick = function(pos, node, clicker)
+ local meta = minetest.get_meta(pos)
+ if has_safe_privilege(meta, clicker) then
+ minetest.show_formspec(
+ clicker:get_player_name(),
+ "currency:safe",
+ default.get_safe_formspec(pos)
+ )
+ end
+ end,
+})
|