From f80ea73bfb668b1999bcc134aaa7fc126724e6d6 Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Sat, 3 Dec 2022 10:41:34 -0500 Subject: Let mods choose a forceload limit (#13002) --- builtin/game/forceloading.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'builtin/game') diff --git a/builtin/game/forceloading.lua b/builtin/game/forceloading.lua index 8043e5dea..52049af16 100644 --- a/builtin/game/forceloading.lua +++ b/builtin/game/forceloading.lua @@ -33,7 +33,7 @@ local function get_relevant_tables(transient) end end -function core.forceload_block(pos, transient) +function core.forceload_block(pos, transient, limit) -- set changed flag forceload_blocks_changed = true @@ -46,7 +46,8 @@ function core.forceload_block(pos, transient) elseif other_table[hash] ~= nil then relevant_table[hash] = 1 else - if total_forceloaded >= (tonumber(core.settings:get("max_forceloaded_blocks")) or 16) then + limit = limit or tonumber(core.settings:get("max_forceloaded_blocks")) or 16 + if limit >= 0 and total_forceloaded >= limit then return false end total_forceloaded = total_forceloaded+1 -- cgit v1.2.3