add ability for Digtron to emerge unloaded map blocks

This commit is contained in:
FaceDeer 2018-06-10 23:00:54 -06:00
parent 1c41a2cdcd
commit 0cb8d2dc33
3 changed files with 15 additions and 8 deletions

@ -61,3 +61,5 @@ setting("int", "power_ratio", 100, "The electrical charge to 1 coal heat unit co
setting("float", "marker_crate_good_duration", 3.0, "Duration that 'good' crate markers last")
setting("float", "marker_crate_bad_duration", 9.0, "Duration that 'bad' crate markers last")
setting("bool", "emerge_unloaded_mapblocks", true, "When Digtron encounters unloaded map blocks, emerge them.")

@ -127,6 +127,9 @@ local function auto_cycle(pos)
status = status .. "\n" .. S("Cycles remaining: @1", cycle) .. "\n" .. S("Halted!")
meta:set_string("infotext", status)
if return_code == 1 then --return code 1 happens when there's unloaded nodes adjacent, just keep trying.
if digtron.config.emerge_unloaded_mapblocks then
minetest.emerge_area(vector.add(pos, -128), vector.add(pos, 128))
end
minetest.after(meta:get_int("period"), auto_cycle, newpos)
else
meta:set_string("formspec", auto_formspec)
@ -145,7 +148,10 @@ local function auto_cycle(pos)
if vector.equals(pos, newpos) then
status = status .. "\n" .. S("Cycles remaining: @1", cycle) .. "\n" .. S("Halted!")
meta:set_string("infotext", status)
if return_code == 1 then --return code 1 happens when there's unloaded nodes adjacent, just keep trying.
if return_code == 1 then --return code 1 happens when there's unloaded nodes adjacent, call emerge and keep trying.
if digtron.config.emerge_unloaded_mapblocks then
minetest.emerge_area(vector.add(pos, -128), vector.add(pos, 128))
end
minetest.after(meta:get_int("period"), auto_cycle, newpos)
else
meta:set_string("formspec", auto_formspec)
@ -286,10 +292,6 @@ minetest.register_node("digtron:auto_controller", {
meta:set_string("waiting", "true")
meta:set_string("formspec", auto_formspec)
end,
on_timer = function(pos, elapsed)
minetest.get_meta(pos):set_string("waiting", nil)
end,
})
---------------------------------------------------------------------------------------------------------------
@ -341,5 +343,4 @@ minetest.register_node("digtron:pusher", {
on_timer = function(pos, elapsed)
minetest.get_meta(pos):set_string("waiting", nil)
end,
})

@ -23,6 +23,10 @@ digtron_maximum_extrusion (Digtron maximum extrusion) int 25 1 100
digtron_marker_crate_good_duration (Duration that 'good' crate markers last) float 3.0 0.0 100.0
digtron_marker_crate_bad_duration (Duration that 'bad' crate markers last) float 9.0 0.0 100.0
#When a Digtron encounters unloaded map blocks, cause them to load
#so that the Digtron can continue moving.
digtron_emerge_unloaded_mapblocks (Emerge unloaded map blocks) bool true
[Fuel costs]
#eg, stone.