summaryrefslogtreecommitdiff
path: root/util_execute_cycle.lua
diff options
context:
space:
mode:
authorFaceDeer <derksenmobile@gmail.com>2017-01-27 19:40:10 -0700
committerFaceDeer <derksenmobile@gmail.com>2017-01-27 19:40:10 -0700
commitbfa9af888abb7b482095d81548194075be913556 (patch)
treeed664a5a2d16cb0e4ae505fbdbeeef531f5af7f5 /util_execute_cycle.lua
parente1c4385471f515b9b91096d5c7cf9ff7a0893d1f (diff)
Add a "stop block" setting to auto-controller
Diffstat (limited to 'util_execute_cycle.lua')
-rw-r--r--util_execute_cycle.lua23
1 files changed, 22 insertions, 1 deletions
diff --git a/util_execute_cycle.lua b/util_execute_cycle.lua
index c23c376..dde9e2d 100644
--- a/util_execute_cycle.lua
+++ b/util_execute_cycle.lua
@@ -76,6 +76,19 @@ local function move_player_test(layout, player)
return false
end
+local function test_stop_block(pos, items)
+ local inv = minetest.get_inventory({type="node", pos=pos})
+ local item_stack = inv:get_stack("stop", 1)
+ if not item_stack:is_empty() then
+ for _, item in pairs(items) do
+ if item == item_stack:get_name() then
+ return true
+ end
+ end
+ end
+ return false
+end
+
-- returns newpos, status string, and a return code indicating why the method returned (so the auto-controller can keep trying if it's due to unloaded nodes)
-- 0 - success
-- 1 - failed due to unloaded nodes
@@ -142,6 +155,10 @@ digtron.execute_dig_cycle = function(pos, clicker)
end
end
+ if test_stop_block(pos, items_dropped) then
+ can_move = false
+ end
+
if not can_move then
-- mark this node as waiting, will clear this flag in digtron.cycle_time seconds
minetest.get_meta(pos):set_string("waiting", "true")
@@ -419,7 +436,11 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
can_move = false
end
end
-
+
+ if test_stop_block(pos, items_dropped) then
+ can_move = false
+ end
+
if not can_move then
-- mark this node as waiting, will clear this flag in digtron.cycle_time seconds
minetest.get_meta(pos):set_string("waiting", "true")