Craft recipe checker -– A tool for debugging mods

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Craft recipe checker -– A tool for debugging mods

by rubenwardy » Fri May 03, 2013 13:34

Recipe checker


This is a code snippet that you can use to check if your craft recipes are valid.

  • When all mods have been loaded, it checks to see if the ingredients in your craft recipes exist
  • If they do not, it issues a warning: [RECIPE ERROR] example:item in recipe for example:item


Download


Github gist: https://gist.github.com/rubenwardy/5504537

I recommend that you add this to builtin. Follow the instructions to do this.

License: WTFPL
If you use this code, then post in this topic, I like knowing that this is useful to someone :P

Example



init.lua
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
<the source here>

minetest.register_craft({
    output = "mod:this 42",
    recipe = {
        {"mod:item","mod:item","mod:item"},
        {"mod:item","noneexistant:item","mod:item"},
        {"mod:item","mod:item","mod:item"},
    }
})


in console
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
[RECIPE ERROR] noneexistant:item in recipe for mod:this


Noticed any bugs? Please tell me!
Last edited by rubenwardy on Mon Jun 09, 2014 18:11, edited 8 times in total.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Fri May 03, 2013 16:04

I have made it so that you do not have to use mod.recipe, it now works with just minetest.register_craft.

Thank you PilzAdam.
Last edited by rubenwardy on Fri May 03, 2013 16:23, edited 1 time in total.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Thu May 09, 2013 12:14

potato!
 

User avatar
Inocudom
Member
 
Posts: 2889
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Thu May 09, 2013 17:33

Another thing you could do with this is see if there are any conflicting recipes (recipes for two different items that are the same.)
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Fri May 10, 2013 10:51

True. Would increase load time a lot.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Wed Sep 18, 2013 08:13

Bump!
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Wed Oct 16, 2013 17:29

bump!
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Fri Jan 17, 2014 22:57

Bump xD
 

User avatar
Pitriss
Member
 
Posts: 253
Joined: Mon Aug 05, 2013 17:09
GitHub: Pitriss
IRC: pitriss
In-game: pitriss

by Pitriss » Fri Jan 17, 2014 23:06

this will be better usable if MT allow to remove broken recipe.. But AFAIK currently is not possible to remove recipes.
I reject your reality and substitute my own. (A. Savage, Mythbusters)
I'm not modding and/or playing minetest anymore. All my mods were released under WTFPL. You can fix/modify them yourself. Don't ask me for support. Thanks.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Fri Jan 17, 2014 23:08

It's a debug tool for mod devs. It's not for players.
 

User avatar
Pitriss
Member
 
Posts: 253
Joined: Mon Aug 05, 2013 17:09
GitHub: Pitriss
IRC: pitriss
In-game: pitriss

by Pitriss » Fri Jan 17, 2014 23:13

I see.. But when you have some game and some mods are git submodules, then this debug is useless as you can't do anything with fact that you have broken recipe except trying to send pull request or creating other mod which add alternate recipe (which make this item craftable, but still, there will be that broken one).:)
I reject your reality and substitute my own. (A. Savage, Mythbusters)
I'm not modding and/or playing minetest anymore. All my mods were released under WTFPL. You can fix/modify them yourself. Don't ask me for support. Thanks.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Craft recipe checker - A tool for debuging mods

by rubenwardy » Mon Jun 09, 2014 17:57

Bump! this has been updated
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: Craft recipe checker -– A tool for debugging mods

by Wuzzy » Wed Oct 22, 2014 17:31

You already know this, but I post it anyways as a reminder:
A crafting slot of the form “group:foo1,foo2” (i.e.: It uses a comma in a crafting group as “logical AND”) will always make the craft recipe checker report an error, although this is a correct notation.
Please fix this, thanks.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Craft recipe checker -– A tool for debugging mods

by rubenwardy » Wed Oct 22, 2014 17:34

That should work, but I will check it out. Are you sure it isn't an error with minetest_game?

https://gist.github.com/rubenwardy/5504 ... it-lua-L17
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: Craft recipe checker -– A tool for debugging mods

by Wuzzy » Wed Oct 22, 2014 19:09

I replaced my old file with the source code you linked, but the recipe error still appears.

I am sure it is not an error with minetest_game.

The minetest_game code we’re talking about registers the crafting recipes which turns flowers into dyes. (place a flower into the crafting grid).

Any item which is a member of the groups “flower” AND “color_something” will produce a dye. These crafting recipes work, I tested it. I also took a quick glance at the dye and flower code. It both makes sense to me.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Craft recipe checker -– A tool for debugging mods

by rubenwardy » Wed Oct 22, 2014 19:15

I think the error may be

for k,v in pairs(flags) do


Where

for i=1, #flags do
v = flags[i]

Should be. I'll check.

Did you install the checker in builtin, or in a mod?
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: Craft recipe checker -– A tool for debugging mods

by Wuzzy » Wed Oct 22, 2014 19:18

Builtin.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Craft recipe checker -– A tool for debugging mods

by rubenwardy » Tue Nov 04, 2014 17:44

That is not a bug with my tool. I have checked it.

dye/init.lua:95
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_craft({
    type = "shapeless",
    output = item_name.." 4",
    recipe = {"group:flower,color_"..name},
})


There is no flower with color_grey in flowers/init.lua. No other mods in minetest_game add items with group:flower.

Added Stack traceback


Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
[RECIPE ERROR] group:flower,color_pink in recipe for dye:pink
stack traceback:
        ...rdy/games/minetest/bin/../builtin/game/mod_debug.lua:112: in function 'register_craft'
        ...inetest/bin/../games/minetest_game/mods/dye/init.lua:95: in main chunk
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: Craft recipe checker -– A tool for debugging mods

by Wuzzy » Fri Jul 29, 2016 20:27

Ah, I understand it now. It took me long enough. :D

The issue is, that it tries to find a gray flower which does not exist of course. This is very likely to be intentional by Minetest Game. A red flower (=rose) exists, however.

I think it is still too harsh to say “error” because clearly the script tries to desperately find some item for a purely group-based craft.
The script could be changed in such a way that it only spits out warnings (not errors) whenever it fails to find any recipe for a purely group-based craft. A craft is purely group-based it ALL of its ingredients are groups instead of concrete items. And exactly this is the case for the dye recipes.

So I think Minetest Game behaves correctly here, since there MAY be another mod installed by someone else which registers a gray flower. ;-) Groups are somewhat special, so they should be treated in a special way.

Oh, and I think “print” is outdated, it should be minetest.log or something.
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

AntumDeluge
Member
 
Posts: 17
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge

Re: Craft recipe checker -– A tool for debugging mods

by AntumDeluge » Tue Sep 06, 2016 13:45

Not sure, but I think there might be a bug:

Log output:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
2016-09-06 06:29:24: ERROR[Server]: RECIPE ERROR: my_old_doors:door1 in recipe for my_old_doors:door1
2016-09-06 06:29:24: [Server]: stack traceback:
   ...inetest-server-testing/bin/../builtin/game/mod_debug.lua:113: in function 'minetest_register_craft'
   ...mes/antum/mods/crafting/craft_guide/craft_guide/init.lua:19: in function 'register_craft'
   ...../games/antum/mods/mp_mydoors/my_old_doors/unlocked.lua:25: in main chunk
   [C]: in function 'dofile'
   ...bin/../games/antum/mods/mp_mydoors/my_old_doors/init.lua:2: in main chunk


Code from my_old_doors:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_craft({
   output = "my_old_doors:door1 1",
   recipe = {
      {"default:glass", "my_door_wood:wood_yellow", ""},
      {"my_door_wood:wood_yellow", "my_door_wood:wood_yellow", ""},
      {"my_door_wood:wood_yellow", "my_door_wood:wood_yellow", ""}
   }
})


According to the error, 'my_old_doors:door1' is in its own recipe. But that is not the case in the code.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Craft recipe checker -– A tool for debugging mods

by rubenwardy » Tue Sep 06, 2016 13:54

Are you sure that's the same code as what you have? The stack traceback says line 25 of unlocked.lua, but there's no craft recipe there, it's half way through one

https://github.com/minetest-mods/mydoor ... ed.lua#L25

Also, this checker also checks output, it's possible that the output is the bit thats wrong

It looks like the output is never defined due to being commented out: https://github.com/minetest-mods/mydoor ... .lua#L2-L5
Last edited by rubenwardy on Tue Sep 06, 2016 13:56, edited 1 time in total.
 

AntumDeluge
Member
 
Posts: 17
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge

Re: Craft recipe checker -– A tool for debugging mods

by AntumDeluge » Tue Sep 06, 2016 13:55

Here is a version that outputs to the debug log: mod_debug.lua
 

AntumDeluge
Member
 
Posts: 17
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge

Re: Craft recipe checker -– A tool for debugging mods

by AntumDeluge » Tue Sep 06, 2016 13:56

rubenwardy wrote:Are you sure that's the same code as what you have? The stack traceback says line 25 of unlocked.lua, but there's no craft recipe there, it's half way through one


Sorry, I was editing my post. I posted the wrong link. It should have been for "unlocked.lua", but I had linked to "locked.lua".
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Craft recipe checker -– A tool for debugging mods

by rubenwardy » Tue Sep 06, 2016 13:58

I think the issue is Ithat output item is never defined due to being commented out: https://github.com/minetest-mods/mydoor ... .lua#L2-L5
 

AntumDeluge
Member
 
Posts: 17
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge

Re: Craft recipe checker -– A tool for debugging mods

by AntumDeluge » Tue Sep 06, 2016 14:04

Yes, you are right. I uncommented the doors & the error goes away. I didn't look at the code closely, but I was a little misguided by the error message.
 

AntumDeluge
Member
 
Posts: 17
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge

Re: Craft recipe checker -– A tool for debugging mods

by AntumDeluge » Tue Sep 06, 2016 14:38

Updated script to check output. And yes, it does take longer to process.

--- Edit ---

FIXME: Script should not process ingredients for output that already failed check.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Craft recipe checker -– A tool for debugging mods

by rubenwardy » Tue Sep 06, 2016 14:58

AntumDeluge wrote:Updated script to check output. And yes, it does take longer to process.

--- Edit ---

FIXME: Script should not process ingredients for output that already failed check.


That change does nothing as my script already checks the output here: https://gist.github.com/AntumDeluge/0df ... g-lua-L113

Even if I didn't already check for it, that would be the wrong place for it as mod.assert is ran once per recipe element, so the output error message would appear that many times
 

AntumDeluge
Member
 
Posts: 17
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge

Re: Craft recipe checker -– A tool for debugging mods

by AntumDeluge » Tue Sep 06, 2016 16:08

I guess I would have to look at the code more closely.

Thank you though, I have already been able to debug a bunch of mods.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 22 guests

cron