From eb68b33ba9608e798823789f813c136f03bbd8ba Mon Sep 17 00:00:00 2001 From: 1F616EMO~nya Date: Sun, 1 Sep 2024 07:13:56 +0800 Subject: [PATCH 1/4] Use vector.offset Co-authored-by: sfan5 --- mods/default/functions.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 3514aebd30..71be44e268 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -306,8 +306,8 @@ function default.dig_up(pos, node, digger, max_height) max_height = max_height or 100 in_dig_up = true - for y = pos.y + 1, pos.y + max_height do - local up_pos = vector.new(pos.x, y, pos.z) + for y = 1, max_height do + local up_pos = vector.offset(pos, 0, y, 0) local up_node = minetest.get_node(up_pos) if up_node.name ~= node.name then break From b5c297c1b73c03f203578f45fd1497ced857228c Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Sun, 1 Sep 2024 07:17:46 +0800 Subject: [PATCH 2/4] use node_dig again, and get rid of pcalls --- game.conf | 2 +- mods/default/functions.lua | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/game.conf b/game.conf index 3f5e35db78..52a773a687 100644 --- a/game.conf +++ b/game.conf @@ -1,4 +1,4 @@ title = Minetest Game author = Minetest description = A basic exploration, mining, crafting, and building, sandbox game with no NPCs, monsters, or animals. Minetest Game is usually used with mods added, and many mods are available for this game. Reliably maintained by Minetest Engine core developers. -min_minetest_version = 5.9 +min_minetest_version = 5.8 diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 71be44e268..1f58af2394 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -312,18 +312,7 @@ function default.dig_up(pos, node, digger, max_height) if up_node.name ~= node.name then break end - local noerr, success = xpcall(function() - return minetest.dig_node(up_pos, digger) - end, function(...) - in_dig_up = false - local errmsg = "Error raised during `default.dig_up` call: " .. minetest.error_handler(...) - for line in errmsg:gmatch("([^\n]*)\n?") do - minetest.log("error", line) - end - end) - if not noerr then - error("Error raised during `default.dig_up` call") - elseif not success then + if not minetest.node_dig(up_pos, up_node, digger) then break end end @@ -334,6 +323,7 @@ minetest.register_globalstep(function() in_dig_up = false end) + -- -- Fence registration helper -- From 5dafdeea48f661cdfd6d5f0ddeafbcd611635d6c Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Sun, 1 Sep 2024 07:21:43 +0800 Subject: [PATCH 3/4] Move things from LDoc to game_api.txt --- game_api.txt | 8 ++++++++ mods/default/functions.lua | 5 ----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/game_api.txt b/game_api.txt index b3f6efc61c..a67ff556d4 100644 --- a/game_api.txt +++ b/game_api.txt @@ -1215,3 +1215,11 @@ These can be influenced using this API. * `player`: ObjectRef of the relevant player * You can override this function to change the weather effects by simply returning different values. Setting `clouds` or `lighting` in the result table to `nil` will *prevent* those from changing. + +Utilities +--------- + +`default.dig_up(pos, node, digger, max_height)` + + * Find all nodes above `pos` that is the same, then dig them all + * `max_height` Maximum number of nodes to iterate. Default: 100 diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 1f58af2394..e13a793284 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -295,11 +295,6 @@ minetest.register_abm({ local in_dig_up = false ----Find all nodes above this one that is the same, then dig them all ----@param pos vector The position of the base node ----@param node { name: string, param1: integer, param2: integer } Node table of the base node ----@param digger ObjectRef The object (e.g. player) digging the node ----@param max_height The maximum height to search for, excluding the base node function default.dig_up(pos, node, digger, max_height) if in_dig_up then return end -- Do not recurse if digger == nil then return end From 45ef266667e41a6f3b2085c89e1f7126363be1ab Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Sun, 1 Sep 2024 07:22:22 +0800 Subject: [PATCH 4/4] Revert version change in init.lua --- mods/default/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/default/init.lua b/mods/default/init.lua index c603ebe8e1..878c5261f0 100644 --- a/mods/default/init.lua +++ b/mods/default/init.lua @@ -17,7 +17,7 @@ default.get_translator = S -- and avoids obscure, hard to debug runtime errors. -- This section should be updated before release and older checks can be dropped -- when newer ones are introduced. -if not minetest.features.node_interaction_actor then +if ItemStack("").add_wear_by_uses == nil then error("\nThis version of Minetest Game is incompatible with your engine version ".. "(which is too old). You should download a version of Minetest Game that ".. "matches the installed engine version.\n")