aboutsummaryrefslogtreecommitdiff
path: root/games/minimal
diff options
context:
space:
mode:
authordarkrose <lisa@ltmnet.com>2012-06-03 20:37:55 +1000
committerPerttu Ahola <celeron55@gmail.com>2012-06-03 22:31:02 +0300
commit3e419ffb38df3f802ed30c5e114b8b3e8b7a6c1f (patch)
treead8f48991e7ed65d127021f4974243ddf5855cbb /games/minimal
parenta149c6ecde66a89bd1080bddf8848a19115a79d4 (diff)
downloadminetest-3e419ffb38df3f802ed30c5e114b8b3e8b7a6c1f.tar.gz
minetest-3e419ffb38df3f802ed30c5e114b8b3e8b7a6c1f.tar.bz2
minetest-3e419ffb38df3f802ed30c5e114b8b3e8b7a6c1f.zip
Add InvRef:is_empty(listname) and make chests/furnaces not diggable if not empty in minimal game
Diffstat (limited to 'games/minimal')
-rw-r--r--games/minimal/mods/default/init.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/games/minimal/mods/default/init.lua b/games/minimal/mods/default/init.lua
index 4468d1e0e..1ffe24837 100644
--- a/games/minimal/mods/default/init.lua
+++ b/games/minimal/mods/default/init.lua
@@ -1147,6 +1147,11 @@ minetest.register_node("default:chest", {
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
+ can_dig = function(pos,player)
+ local meta = minetest.env:get_meta(pos);
+ local inv = meta:get_inventory()
+ return inv:is_empty("main")
+ end,
on_metadata_inventory_move = function(pos, from_list, from_index,
to_list, to_index, count, player)
minetest.log("action", player:get_player_name()..
@@ -1200,6 +1205,11 @@ minetest.register_node("default:chest_locked", {
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
+ can_dig = function(pos,player)
+ local meta = minetest.env:get_meta(pos);
+ local inv = meta:get_inventory()
+ return inv:is_empty("main")
+ end,
on_metadata_inventory_move = function(pos, from_list, from_index,
to_list, to_index, count, player)
local meta = minetest.env:get_meta(pos)
@@ -1270,6 +1280,18 @@ minetest.register_node("default:furnace", {
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
+ can_dig = function(pos,player)
+ local meta = minetest.env:get_meta(pos);
+ local inv = meta:get_inventory()
+ if not inv:is_empty("fuel") then
+ return false
+ elseif not inv:is_empty("dst") then
+ return false
+ elseif not inv:is_empty("src") then
+ return false
+ end
+ return true
+ end,
})
minetest.register_node("default:furnace_active", {
@@ -1291,6 +1313,18 @@ minetest.register_node("default:furnace_active", {
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
+ can_dig = function(pos,player)
+ local meta = minetest.env:get_meta(pos);
+ local inv = meta:get_inventory()
+ if not inv:is_empty("fuel") then
+ return false
+ elseif not inv:is_empty("dst") then
+ return false
+ elseif not inv:is_empty("src") then
+ return false
+ end
+ return true
+ end,
})
function hacky_swap_node(pos,name)