minetest-mods / item_drop

A highly configurable mod providing item magnet and in-world node drops
https://forum.minetest.net/viewtopic.php?t=16913
GNU Lesser General Public License v2.1
13 stars 12 forks source link

Does not work with 5.3.0-dev due to changes in item entity params #32

Closed VanessaE closed 4 years ago

VanessaE commented 4 years ago
2020-05-07 17:37:25: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'default' in callback luaentity_Step(): /usr/local/share/minetest/builtin/game/item_entity.lua:203: assertion failed!
2020-05-07 17:37:25: ERROR[Main]: stack traceback:
2020-05-07 17:37:25: ERROR[Main]:   [C]: in function 'assert'
2020-05-07 17:37:25: ERROR[Main]:   /usr/local/share/minetest/builtin/game/item_entity.lua:203: in function 'on_step'
2020-05-07 17:37:25: ERROR[Main]:   ...inetest/games/minetest_game/mods/default/item_entity.lua:43: in function <...inetest/games/minetest_game/mods/default/item_entity.lua:42>

Please apply this patch to fix it:

diff --git a/init.lua b/init.lua
index bc0fc1a..42d3ff6 100644
--- a/init.lua
+++ b/init.lua
@@ -201,9 +201,9 @@ if legacy_setting_getbool("item_drop.enable_item_pickup",
                        local itemdef = minetest.registered_entities["__builtin:item"]
                        local old_on_step = itemdef.on_step
                        local function do_nothing() end
-                       function itemdef.on_step(self, dtime)
+                       function itemdef.on_step(self, dtime, ...)
                                if not self.is_magnet_item then
-                                       return old_on_step(self, dtime)
+                                       return old_on_step(self, dtime, ...)
                                end
                                ObjectRef = ObjectRef or getmetatable(self.object)
                                local old_funcs = {}
@@ -212,7 +212,7 @@ if legacy_setting_getbool("item_drop.enable_item_pickup",
                                        old_funcs[method] = ObjectRef[method]
                                        ObjectRef[method] = do_nothing
                                end
-                               old_on_step(self, dtime)
+                               old_on_step(self, dtime, ...)
                                for i = 1, #blocked_methods do
                                        local method = blocked_methods[i]
                                        ObjectRef[method] = old_funcs[method]

Thanks to @sofar for this fix.

HybridDog commented 4 years ago

I've applied the changes and also removed the explicit dtime. https://github.com/minetest-mods/item_drop/commit/72f4225058e43a1d0a675e3fb18997abac67011d