minetest_game
minetest_game copied to clipboard
craftguide crash: attempt to get length of field 'recipes' (a nil value)
minetest core version 5.4 & 5.5-dev (server/multiplayer) MTG update at commit 0a90bd8a0ec530f48e1bd9a438e24bd85cc9cd66
Server crash: 2021-04-01 17:42:40: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'sfinv' in callback on_playerReceiveFields(): .../bin/../games/minetest_game/mods/mtg_craftguide/init.lua:372: attempt to get length of field 'recipes' (a nil value) 2021-04-01 17:42:40: ERROR[Main]: stack traceback: 2021-04-01 17:42:40: ERROR[Main]: .../bin/../games/minetest_game/mods/mtg_craftguide/init.lua:372: in function 'on_receive_fields' 2021-04-01 17:42:40: ERROR[Main]: .../bin/../games/minetest_game/mods/mtg_craftguide/init.lua:430: in function <.../bin/../games/minetest_game/mods/mtg_craftguide/init.lua:429> 2021-04-01 17:42:40: ERROR[Main]: /home/minetest/minetest/bin/../builtin/game/register.lua:425: in function </home/minetest/minetest/bin/../builtin/game/register.lua:409>
https://github.com/minetest/minetest_game/blob/0a90bd8a0ec530f48e1bd9a438e24bd85cc9cd66/mods/mtg_craftguide/init.lua#L370-L378
How to reproduce?
idk
It looks like someone created a craft recipe without the recipe. Perhaps "recipe” was spelled wrong?
minetest.register_craft({
output = “foo”,
repice = {“bar”, “baz”},
})
Edit: Actally, I didn’t look closely at the code @SmallJoker posted. I think I am way off.
https://github.com/minetest/minetest_game/blob/0a90bd8a0ec530f48e1bd9a438e24bd85cc9cd66/mods/mtg_craftguide/init.lua#L370-L378
Should probably be a sanity check anywhere data.recipies is used to ensure that it is not nil before using it.
elseif (data.recipes ~= nil) and (fields.recipe_next or fields.recipe_prev) then
data.rnum = data.rnum + (fields.recipe_next and 1 or -1)
if data.rnum > #data.recipes then
data.rnum = 1
elseif data.rnum == 0 then
data.rnum = #data.recipes
end
return true