From c86e2f3fbca57e7943e2b2322eb4d69c49e3bf63 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Fri, 13 Jan 2023 09:58:58 -0400 Subject: [PATCH] add forward compatibility with MT 5 for the ancient nodeupdate(pos) * replace if the new minetest api is detected the `nodeupdate(pos)` with the new `check_for_falling(pos)` api since 5.0 but mantains backguard compatibility with 4.0.13 to 4.0.16 * use the new expose version check flags from `adventuretest` mod so the fire n doors mods must depends on default or adventuretest * add to respective notes such change --- NOTES.md | 56 +------------------------------------- mods/default/functions.lua | 6 +++- mods/doors/init.lua | 6 +++- mods/fire/init.lua | 6 +++- 4 files changed, 16 insertions(+), 58 deletions(-) diff --git a/NOTES.md b/NOTES.md index 67a01a5..aa7e618 100644 --- a/NOTES.md +++ b/NOTES.md @@ -5,6 +5,7 @@ There are the issues Tignasse Verte mentionned: Adding `placer` in `register_functions.lua` (related commit for minenux are commit a996d5ac709446322d6c6261c21e5f0752a6aeeb ) and replacing the two occourances of `nodeupdate` with `minetest.check_for_falling`. +(relatd commit for minenux are commit 8c53cabfce2d079df76e57b27b020e016837e8fc ) Other changes are necessary because I changed (and had to change) quite a lot in `mg_villages` internally recently. If you want to get further with running @@ -28,61 +29,6 @@ Mobs will likely not work very well. A lot changed regarding them. They certainly could use an update as well - as could the goblins. I'm sure the witches from the same modder would feel welcome in the AdventureTest universe, too. -###### now the changes in fact: - -DFeniks wrote: -2020-01-07 10:02:08: ERROR[Main]: ServerError: AsyncErr: Lua: finishGenRuntime error from mod 'default' in callback item_OnPlace(): ...enturetest/mods/adventuretest/register_functions.lua:101: attempt to index local 'placer' (a nil value) - -Reason on server-side : - -Here are the changes made on server-side, concerning item_OnPlace, for the 5.X.X : -https://dev.minetest.net/Changelog, -0.4.16 → 5.0.0 , Released March 4th 2019 / Server-side / User interface / Items - -Set placer to nil instead of a non-functional one in item_OnPlace (DTA7) -Here is why, you may have a nil placer. One issue had been logged : -https://github.com/minetest/minetest/issues/6487 -place_node crashes the game because of nil player #6487 - -Here is the commit corresponding : -https://github.com/minetest/minetest_game/pull/1907/commits/73c5339adb8ff93328f5439bf842767b71e0ce6c -Add nil checks for placer #1907 - -Reason in the mod : -For Adventure Test, in `dungeons.lua`, you have line 33 a `minetest.register_on_generated()`, -in it, you have, line 161, a call of `minetest.place_node()`. - -In `register_functions.lua`, you have a `minetest.register_on_placenode(adventuretest_placenode)`, -so the call of `place_node()` redirect to `adventuretest_placenode()`. -In the commit, I have found an example of change (a nil check) that can be done -in `adventuretest_placenode()`. - -What to do : -Go to : -games\adventuretest\mods\adventuretest -There, change the file : -`register_functions.lua` replace the line 101 (`if placer:is_player() then`) with : - -``` -if placer and placer:is_player() then -``` - -0.4.16 → 5.0.0 : -`nodeupdate()` was removed. Fix: replace with `minetest.check_for_falling`. - -In Adventuretest I have found 2 calls of `nodeupdate()` (may be there is more). -When it have been called, I got a crash : -`AsyncErr: ServerThread::run Lua: Runtime error from mod 'default' in callback LuaABM::trigger(): ...32\bin\..\games\adventuretest\mods\default/functions.lua:385: attempt to call global 'nodeupdate' (a nil value)` - -What to do : -Change the file -`games\adventuretest\mods\default\functions.lua` -replace the line 385 (nodeupdate(p0)) with : -`minetest.check_for_falling(p0)` - -Then, change the file `games\adventuretest\mods\doors\init.lua` replace the line 374 with : -`minetest.check_for_falling({x = pos.x, y = pos.y + 1, z = pos.z})` - ### Fiel of view for monsters vs characters From https://forum.minetest.net/viewtopic.php?p=182737#p182737 diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 3fc831d..a4ae174 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -382,7 +382,11 @@ minetest.register_abm({ end -- Remove node minetest.remove_node(p0) - nodeupdate(p0) + if adventuretest.is_50 then + minetest.check_for_falling(p0) + else + nodeupdate(p0) + end end end }) diff --git a/mods/doors/init.lua b/mods/doors/init.lua index 2562730..5711a94 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -371,7 +371,11 @@ function doors.register(name, def) end def.after_dig_node = function(pos, node, meta, digger) minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) - nodeupdate({x = pos.x, y = pos.y + 1, z = pos.z}) + if adventuretest.is_50 then + minetest.check_for_falling({x = pos.x, y = pos.y + 1, z = pos.z}) + else + nodeupdate({x = pos.x, y = pos.y + 1, z = pos.z}) + end end def.can_dig = function(pos, player) return can_dig(pos, player) diff --git a/mods/fire/init.lua b/mods/fire/init.lua index 4552586..6b54582 100644 --- a/mods/fire/init.lua +++ b/mods/fire/init.lua @@ -239,7 +239,11 @@ else local p = minetest.find_node_near(p0, 1, {"group:flammable"}) if p then minetest.remove_node(p) - nodeupdate(p) + if adventuretest.is_50 then + minetest.check_for_falling(p) + else + nodeupdate(p) + end end end end,