aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/game/forceloading.lua5
-rw-r--r--builtin/settingtypes.txt5
-rw-r--r--doc/lua_api.txt6
3 files changed, 11 insertions, 5 deletions
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
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index 845564264..8a8425ca0 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -1875,8 +1875,9 @@ active_block_range (Active block range) int 4 1 65535
# From how far blocks are sent to clients, stated in mapblocks (16 nodes).
max_block_send_distance (Max block send distance) int 12 1 65535
-# Maximum number of forceloaded mapblocks.
-max_forceloaded_blocks (Maximum forceloaded blocks) int 16 0
+# Default maximum number of forceloaded mapblocks.
+# Set this to -1 to disable the limit.
+max_forceloaded_blocks (Maximum forceloaded blocks) int 16 -1
# Interval of sending time of day to clients, stated in seconds.
time_send_interval (Time send interval) float 5.0 0.001
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index e9a95c9e7..e8e32c536 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -6532,12 +6532,16 @@ Misc.
* You may want to cache and call the old function to allow multiple mods to
change knockback behavior.
-* `minetest.forceload_block(pos[, transient])`
+* `minetest.forceload_block(pos[, transient[, limit]])`
* forceloads the position `pos`.
* returns `true` if area could be forceloaded
* If `transient` is `false` or absent, the forceload will be persistent
(saved between server runs). If `true`, the forceload will be transient
(not saved between server runs).
+ * `limit` is an optional limit on the number of blocks that can be
+ forceloaded at once. If `limit` is negative, there is no limit. If it is
+ absent, the limit is the value of the setting `"max_forceloaded_blocks"`.
+ If the call would put the number of blocks over the limit, the call fails.
* `minetest.forceload_free_block(pos[, transient])`
* stops forceloading the position `pos`