Generating craft example images

User avatar
Bas080
Member
 
Posts: 398
Joined: Mon May 21, 2012 15:54
GitHub: bas080
IRC: bas080
In-game: bas080

Generating craft example images

by Bas080 » Wed Jun 11, 2014 00:32

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?
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: Generating craft example images

by Sokomine » Wed Jun 11, 2014 02:51

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.
 

Kilarin
Member
 
Posts: 649
Joined: Mon Mar 10, 2014 00:36

Re: Generating craft example images

by Kilarin » Wed Jun 11, 2014 04:51

I really like this idea! I second Sokomine on putting a small frame between the items and showing the result.
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

Re: Generating craft example images

by philipbenr » Wed Jun 11, 2014 14:24

Looks amazing to me. This will help immensely for my mods. Thank you Stu!
 

User avatar
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

Re: Generating craft example images

by Calinou » Wed Jun 11, 2014 17:42

Is there a way to upscale the output, without blurring, to have a larger preview ? The ones generated here are quite small.
 

User avatar
Casimir
Member
 
Posts: 1101
Joined: Fri Aug 03, 2012 16:59

Re: Generating craft example images

by Casimir » Wed Jun 11, 2014 20:16

Gimp, scale, choose no method, choose a multiple of the pixels, scale.
Image
Attachments
craft_furnace.png
craft_furnace.png (1.4 KiB) Viewed 1059 times
 

User avatar
Bas080
Member
 
Posts: 398
Joined: Mon May 21, 2012 15:54
GitHub: bas080
IRC: bas080
In-game: bas080

Re: Generating craft example images

by Bas080 » Thu Jun 12, 2014 00:32

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.
 

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

Re: Generating craft example images

by rubenwardy » Thu Jun 12, 2014 07:47

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.
 

User avatar
Bas080
Member
 
Posts: 398
Joined: Mon May 21, 2012 15:54
GitHub: bas080
IRC: bas080
In-game: bas080

Re: Generating craft example images

by Bas080 » Thu Jun 12, 2014 15:27

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...
 

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

Re: Generating craft example images

by rubenwardy » Thu Jun 12, 2014 17:36

This is quite similar to the craft recipe PHP project.
 

User avatar
Casimir
Member
 
Posts: 1101
Joined: Fri Aug 03, 2012 16:59

Re: Generating craft example images

by Casimir » Thu Jun 12, 2014 18:22

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.
 

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

Re: Generating craft example images

by rubenwardy » Fri Jun 13, 2014 08:16

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"
 

User avatar
Casimir
Member
 
Posts: 1101
Joined: Fri Aug 03, 2012 16:59

Re: Generating craft example images

by Casimir » Fri Jun 13, 2014 09:41

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.
 


Return to Minetest-Related

Who is online

Users browsing this forum: No registered users and 21 guests

cron