Page 1 of 1

[SOLVED] "Invalid crafting recipe" (noob error)

PostPosted: Thu Jul 28, 2016 11:47
by taikedz
Hello

I'm trying to add some useful things to do with some craft items that have no recipes, so trying to define my own separate mod to do so.

I have created a myrecipes/ dir in which I have this depends.txt

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
mobs
mobs_zombie
mobs_slimes


and this 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
cslime = "mobs_slimes:green_slimeball"
zflesh = "mobs_zombie:rotten_flesh"

minetest.register_craft({
        output = "mobs:meat_raw",
        type = "shapeless",
        recipe = {
                {cslime,cslime,cslime},
                {zflesh,zflesh,zflesh},
        }
})


On trying to load the game with the associated dependencies, I get

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
Invalid crafting recipe (out="mobs:meat_raw")


I've gone over this a few times now and cannot spot the mistake I am making.... I tried speciying output = ":mobs:meat_raw" but that still errors. I tried also using default:wood, which errors.

I have done some crafting recipes elsewhere which work and I see no obvious differences - so why is it not working here?

Re: "Invalid crafting recipe" (noob error?)

PostPosted: Thu Jul 28, 2016 13:52
by Krock
For the shapeless type you don't need to specify each row of the crafting grid. It also crashes Minetest instantly here.
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 = "mobs:meat_raw",
        type = "shapeless",
        recipe = {
                cslime,cslime,cslime,
                zflesh,zflesh,zflesh
        }
})

Re: "Invalid crafting recipe" (noob error?)

PostPosted: Thu Jul 28, 2016 13:55
by KCoombes
taikedz wrote:-snip-

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
cslime = "mobs_slimes:green_slimeball"
zflesh = "mobs_zombie:rotten_flesh"

minetest.register_craft({
        output = "mobs:meat_raw",
        type = "shapeless",
        recipe = {
                {cslime,cslime,cslime},
                {zflesh,zflesh,zflesh},
        }
})


Any particular reason you're using {cslime,cslime,cslime}, rather than {"mobs_slimes:green_slimeball","mobs_slimes:green_slimeball","mobs_slimes:green_slimeball"}, ?

Re: "Invalid crafting recipe" (noob error?)

PostPosted: Thu Jul 28, 2016 17:08
by taikedz
Krock wrote:For the shapeless type you don't need to specify each row of the crafting grid.


That was the problem exactly. Though that's a very misleading error message! Never would have figured that one out. Thanks Krock

KCoombes wrote:Any particular reason you're using {cslime,cslime,cslime}, rather than {"mobs_slimes:green_slimeball","mobs_slimes:green_slimeball","mobs_slimes:green_slimeball"}, ?


DRY principle? Conciseness? Clarity? Ocular parsing facilitation?

Why would you not?

Re: "Invalid crafting recipe" (noob error?)

PostPosted: Thu Jul 28, 2016 17:16
by everamzah
You're creating local variables for strings that are accessed only once during load-time, though I believe this is trivial.

Edit: On second look, they're actually global variables.

Ps. What's the DRY principle?

Re: "Invalid crafting recipe" (noob error?)

PostPosted: Thu Jul 28, 2016 22:42
by Byakuren
everamzah wrote:You're creating local variables for strings that are accessed only once during load-time, though I believe this is trivial.

Edit: On second look, they're actually global variables.

Ps. What's the DRY principle?

"Don't Repeat Yourself"

I do this too when strings are long and used several times in the same recipe.

Re: "Invalid crafting recipe" (noob error?)

PostPosted: Fri Jul 29, 2016 11:27
by taikedz
everamzah wrote:Edit: On second look, they're actually global variables.


I keep forgetting that they're global by default. Thanks