Page 1 of 1

Generating craft example images

PostPosted: Wed Jun 11, 2014 00:32
by Bas080
Most modders preffer sharing the work they did on the forum. Showing players how to craft stuff is part of that. We often see things like:

s = stick
x = stone
e = empty

Craft
e s e
e x e
e e e

It is nicer to see images as symbols. Imagemagick allows the appending of images.

I wrote a simple bash script to get this project started. It uses imagemagick (sudo apt-get install imagemagick). Here it is:

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
convert \( $1 $2 $3 +append \) \
        \( $4 $5 $6 +append \) \
        \( $7 $8 $9 +append \) \
        -background none -append "craft_$10.png"


An example of a result is:
Image

Another would be
Image

I'm looking forward on developing this further so it would automagically generate crafts with the input of an init.lua. Any suggestions on the best way to do this?

Re: Generating craft example images

PostPosted: Wed Jun 11, 2014 02:51
by Sokomine
Sounds very good. I find it very annoying to take those screenshots, and when I take them, they vary in size. Generating them with a script would be much more convenient.

In your sample, the three wooden planks are difficult to distinguish. There ought to be some frame around them. And also an extra slot for the resulting item.

Re: Generating craft example images

PostPosted: Wed Jun 11, 2014 04:51
by Kilarin
I really like this idea! I second Sokomine on putting a small frame between the items and showing the result.

Re: Generating craft example images

PostPosted: Wed Jun 11, 2014 14:24
by philipbenr
Looks amazing to me. This will help immensely for my mods. Thank you Stu!

Re: Generating craft example images

PostPosted: Wed Jun 11, 2014 17:42
by Calinou
Is there a way to upscale the output, without blurring, to have a larger preview ? The ones generated here are quite small.

Re: Generating craft example images

PostPosted: Wed Jun 11, 2014 20:16
by Casimir
Gimp, scale, choose no method, choose a multiple of the pixels, scale.
Image

Re: Generating craft example images

PostPosted: Thu Jun 12, 2014 00:32
by Bas080
Casimir, the goal is to generate them automatically. Not requiring the modder to do this with gimp. Imagemagick allows the scaling of an image. Thus this can be automated.

Sokomine, i agree that the resulting craft image should also be shown. Good idea and a +1.

Anyone with some technical know how on how to interpret the lua file (regex maybe?). Let me know as I am having difficulties on the best way to do this.

EDIT: Sokomine, a grid shouldn't be that hard to add also.

Re: Generating craft example images

PostPosted: Thu Jun 12, 2014 07:47
by rubenwardy
This looks very good. Could you add a small margin between the images?

Bas080 wrote:Anyone with some technical know how on how to interpret the lua file (regex maybe?). Let me know as I am having difficulties on the best way to do this.


regex will be very fiddly. You could instead use a lua interpreter, and make all the minetest.* functions like this:

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
function minetest.register_entity(name,data)

end


except the relevant defining functions.

Can you run stand alone Lua like Python? Shouldn't be too hard...

However, this will not work if the mod uses another mod's functions, or adds items depending on whether a mod exists.

Regex would be the most effective way, but will be hard and fiddly to develop.

Maybe do a compromise, and get the user to only paste the register definition, rather than the whole init.lua file.

You could also do this as a Minetest mod.

Re: Generating craft example images

PostPosted: Thu Jun 12, 2014 15:27
by Bas080
Rubenwardy,
You could also do this as a Minetest mod.

Imo that is the neatest solution.

Am suggesting a command "/genrec <name of item/node/tool or a lua regex to select multiple>" which then generates the recipe(s) and the output of them.

Also imagemagick allows the making of 3d boxes. It would be nice to make the nodes 3d boxes in the recipe. Is there a way to check if something is a node or an item? Looking up...

Re: Generating craft example images

PostPosted: Thu Jun 12, 2014 17:36
by rubenwardy
This is quite similar to the craft recipe PHP project.

Re: Generating craft example images

PostPosted: Thu Jun 12, 2014 18:22
by Casimir
Bas080 wrote:Is there a way to check if something is a node or an item?

I think minetest.registered_nodes only returns true for nodes and false for craftitems, while minetest.registered_items returns true for both nodes and craftitems.

Re: Generating craft example images

PostPosted: Fri Jun 13, 2014 08:16
by rubenwardy
What Casimir means to say is craft items and tools are in minetest.registered_items, but not in minetest.registered_nodes.

Nodes are in both.

Also I think the definition has a type parametre. Something like minetest.registered_items["default:stick"].type == "craftitem"

Re: Generating craft example images

PostPosted: Fri Jun 13, 2014 09:41
by Casimir
Yes. When you look into /minetest/builtin/game/item.lua you will see type is "node" for nodes "craft" for craftitems "tool" for tools and "none" for the hand.