mirror of
https://github.com/minetest-mods/digtron.git
synced 2024-12-22 12:22:22 +01:00
limit size of the digtron with config option: digtron_size_limit, default to 1000 nodes (#52)
This commit is contained in:
parent
b3d01a714c
commit
445140abaa
@ -27,6 +27,7 @@ setting("bool", "uses_resources", true, "Digtron uses resources when active")
|
|||||||
setting("bool", "lava_impassible", true, "Lava counts as a protected node")
|
setting("bool", "lava_impassible", true, "Lava counts as a protected node")
|
||||||
setting("bool", "damage_creatures", true, "Diggers damage creatures") -- TODO: legacy setting, remove eventually
|
setting("bool", "damage_creatures", true, "Diggers damage creatures") -- TODO: legacy setting, remove eventually
|
||||||
setting("int", "damage_hp", 8, "Damage diggers do")
|
setting("int", "damage_hp", 8, "Damage diggers do")
|
||||||
|
setting("int", "size_limit", 1000, "Digtron size limit in nodes per moving digtron")
|
||||||
|
|
||||||
if digtron.config.damage_creatures == false then digtron.config.damage_hp = 0 end -- TODO: remove when damage_creatures is removed
|
if digtron.config.damage_creatures == false then digtron.config.damage_hp = 0 end -- TODO: remove when damage_creatures is removed
|
||||||
|
|
||||||
|
@ -95,6 +95,12 @@ local function test_stop_block(pos, items)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function check_digtron_size(layout)
|
||||||
|
if #layout.all > digtron.config.size_limit then
|
||||||
|
return S("Size limit of @1 reached with @2 nodes!", digtron.config.size_limit, #layout.all)
|
||||||
|
end
|
||||||
|
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)
|
-- 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
|
-- 0 - success
|
||||||
-- 1 - failed due to unloaded nodes
|
-- 1 - failed due to unloaded nodes
|
||||||
@ -104,6 +110,7 @@ end
|
|||||||
-- 5 - unknown builder error during testing
|
-- 5 - unknown builder error during testing
|
||||||
-- 6 - builder with unset output
|
-- 6 - builder with unset output
|
||||||
-- 7 - insufficient builder materials in inventory
|
-- 7 - insufficient builder materials in inventory
|
||||||
|
-- 8 - size/node limit reached
|
||||||
digtron.execute_dig_cycle = function(pos, clicker)
|
digtron.execute_dig_cycle = function(pos, clicker)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local facing = minetest.get_node(pos).param2
|
local facing = minetest.get_node(pos).param2
|
||||||
@ -119,6 +126,11 @@ digtron.execute_dig_cycle = function(pos, clicker)
|
|||||||
return pos, status_text, return_code
|
return pos, status_text, return_code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local size_check_error = check_digtron_size(layout)
|
||||||
|
if size_check_error then
|
||||||
|
return pos, size_check_error, 8
|
||||||
|
end
|
||||||
|
|
||||||
local controlling_coordinate = digtron.get_controlling_coordinate(pos, facing)
|
local controlling_coordinate = digtron.get_controlling_coordinate(pos, facing)
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------------
|
||||||
@ -405,6 +417,11 @@ digtron.execute_move_cycle = function(pos, clicker)
|
|||||||
return pos, status_text, return_code
|
return pos, status_text, return_code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local size_check_error = check_digtron_size(layout)
|
||||||
|
if size_check_error then
|
||||||
|
return pos, size_check_error, 8
|
||||||
|
end
|
||||||
|
|
||||||
local facing = minetest.get_node(pos).param2
|
local facing = minetest.get_node(pos).param2
|
||||||
local dir = minetest.facedir_to_dir(facing)
|
local dir = minetest.facedir_to_dir(facing)
|
||||||
local controlling_coordinate = digtron.get_controlling_coordinate(pos, facing)
|
local controlling_coordinate = digtron.get_controlling_coordinate(pos, facing)
|
||||||
@ -460,6 +477,12 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
|
|||||||
return pos, status_text, return_code
|
return pos, status_text, return_code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local size_check_error = check_digtron_size(layout)
|
||||||
|
if size_check_error then
|
||||||
|
return pos, size_check_error, 8
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local controlling_coordinate = digtron.get_controlling_coordinate(pos, facing)
|
local controlling_coordinate = digtron.get_controlling_coordinate(pos, facing)
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user