nil value on create_inventory
Closed this issue · 8 comments
ServerError: Lua: Runtime error from mod 'craft_guide' in callback node_on_receive_fields(): ...ld/worldmods/craft_guide/craft_guide/api_craft_guide.lua:1835: attempt to index a nil value
stack traceback:
...ld/worldmods/craft_guide/craft_guide/api_craft_guide.lua:1835: in function 'create_inventory'
...ld/worldmods/craft_guide/craft_guide/api_craft_guide.lua:921: in function <...ld/worldmods/craft_guide/craft_guide/api_craft_guide.lua:422>
This makes it nearly unusuable. :/
Hey @tchncs,
This code is kind of held together with bubblegum and string.
If you have a fix feel free to do a PR.
Owww, this is really sad to hear.
The players enjoy this kind of craftguide the very most.
I hope to be able to fix this somewhen - the feel is there, but the knowledge is missing. -.-
Hello, I stopped playing minetest myself and so I lost personel interest in modding for it.
But I'm back now and I will see what I can do to fix the open issues so this crafting guide will work with new minetest versions again.
This issue should be easy to fix, just one more check needed where the error happens. Seems a recipe which got deleted causing this error.
api_craft_guide.lua:line 1835:
if craft~=nil and craft[0]=nil and ((craft[1]).type="fuel" or craft_guide.show_all_fuel_crafts) then
@Miner59 sorry for the late response.
I was guessing the deleted part should be a ~
so it would be
if craft~=nil and craft[0]~=nil and ((craft[1]).type~="fuel" or craft_guide.show_all_fuel_crafts) then
Good news: no crash
Bad news: no recipes :P
Edit: i tried
if craft~=nil and ((craft[0]).type~="fuel") and ((craft[1]).type~="fuel" or craft_guide.show_all_fuel_crafts) then
and the error is back...
Oh yes, it needs to be "craft[1]" instead of "craft[0]".
I have no clue why I made this mistake and wrote "craft[0]".
Otherwise your first attempt was right.
So this needs to be on api_craft_guide.lua,line 1835:
if craft~=nil and craft[1]~=nil and ((craft[1]).type~="fuel" or craft_guide.show_all_fuel_crafts) then
Oh yeah, it seems to work, thank you! ❤️
I submitted a pull request for this issue based on what @Miner59 and @tchncs worked out above. Should make the craft guide usable again. Thanks for doing the hard part!
fixed in #19