Craft recipe checker -– A tool for debugging mods

User avatar
rubenwardy
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Craft recipe checker -– A tool for debugging mods

by rubenwardy » Post

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

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

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.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
rubenwardy
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

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.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
rubenwardy
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

potato!
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

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

by Inocudom » Post

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
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

True. Would increase load time a lot.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
rubenwardy
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

Bump!
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
rubenwardy
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

bump!
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
rubenwardy
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

Bump xD
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Pitriss
Member
Posts: 254
Joined: Mon Aug 05, 2013 17:09
GitHub: Pitriss
IRC: pitriss
In-game: pitriss
Location: Czech republic, Bohumin

by Pitriss » Post

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
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

It's a debug tool for mod devs. It's not for players.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Pitriss
Member
Posts: 254
Joined: Mon Aug 05, 2013 17:09
GitHub: Pitriss
IRC: pitriss
In-game: pitriss
Location: Czech republic, Bohumin

by Pitriss » Post

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
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: Craft recipe checker - A tool for debuging mods

by rubenwardy » Post

Bump! this has been updated
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

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

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

by Wuzzy » Post

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
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

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

by rubenwardy » Post

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
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

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

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

by Wuzzy » Post

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
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

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

by rubenwardy » Post

I think the error may be

for k,v in pairs(flags) do


Where

for i=1, #flags do
v = flags

Should be. I'll check.

Did you install the checker in builtin, or in a mod?
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

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

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

by Wuzzy » Post

Builtin.

User avatar
rubenwardy
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

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

by rubenwardy » Post

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

dye/init.lua:95

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

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
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

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

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

by Wuzzy » Post

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.

User avatar
AntumDeluge
Member
Posts: 213
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge
Contact:

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

by AntumDeluge » Post

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

Log output:

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:

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
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

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

by rubenwardy » Post

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.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
AntumDeluge
Member
Posts: 213
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge
Contact:

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

by AntumDeluge » Post

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

User avatar
AntumDeluge
Member
Posts: 213
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge
Contact:

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

by AntumDeluge » Post

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
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

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

by rubenwardy » Post

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
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
AntumDeluge
Member
Posts: 213
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge
Contact:

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

by AntumDeluge » Post

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests