Problem with registration of node.

Post Reply
User avatar
Andrey01
Member
Posts: 2577
Joined: Wed Oct 19, 2016 15:18
GitHub: Andrey2470T
In-game: Andrey01
Location: Russia, Moscow

Problem with registration of node.

by Andrey01 » Post

I am developing cube_nodes mod and i want to add a chance to paint the nodes in different colors by right-clicking dyes. But i have a lot of nodes with various images and that`s why i need to register each node with every possible colors (for example, "node_A" needs to be registered with red, pink, brown, green, blue colors and so each node). Any other way that would do without registration of so huge amount of nodes?

User avatar
csirolli
Member
Posts: 133
Joined: Mon Jan 15, 2018 21:46
GitHub: HeyITGuyFixIt
IRC: CSirolli
In-game: CSirolli
Location: Florida, USA
Contact:

Re: Problem with registration of node.

by csirolli » Post

If you are concerned about creating code for each node, you could store all of the supported colors together in an array and loop through that array, so you are writing the code only once. I don't know of any way to reduce the actual amount of registered nodes. However, you may be able to use meta data to add color overlays. I don't know anything about meta data yet, so I don't know if that is a viable possibility.

User avatar
Andrey01
Member
Posts: 2577
Joined: Wed Oct 19, 2016 15:18
GitHub: Andrey2470T
In-game: Andrey01
Location: Russia, Moscow

Re: Problem with registration of node.

by Andrey01 » Post

Ok, thanks for answer. If it would be possible to add meta data it would be just nice and i would not need to register so huge amount of painted nodes.

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Problem with registration of node.

by Krock » Post

You can indeed create up to 256 different colored nodes with only one node definition. The trick behind this is using palettes. However, this feature is rather new and thus, not used much yet.
Documentation of the theory: https://github.com/minetest/minetest/bl ... #L564-L588
Documentation of the node definition: https://github.com/minetest/minetest/bl ... 5144-L5152

GLP v3 code example: https://github.com/4w/cement/blob/maste ... ua#L10-L43 (found here)
LGPL v2.1+ code example: viewtopic.php?f=9&t=18862

PS: @Andrey01: Please be a bit more patient. Sending PMs does not increase the chance much to get a reply on a topic.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Andrey01
Member
Posts: 2577
Joined: Wed Oct 19, 2016 15:18
GitHub: Andrey2470T
In-game: Andrey01
Location: Russia, Moscow

Re: Problem with registration of node.

by Andrey01 » Post

It seems so way doesn`t fit. Let me tell in more detail that i want to do: i want to register only node, it will look like here:

Image

Then i want to create "node painter" that will paint those white nodes, as it imagines on the image above. It will contain a formspec where player puts a dye and this machine outputs already painted node in according color. But it will paint the node only at edges and distinguish image inside as letter, number, punctuation marks. Then to paint remaining unpainted parts of nodes player needs to take a dye and right-click it. It will paint to according color. It`s all. But suggested API by you allows only to paint a node in only color entirely. Is there anything other way?

User avatar
csirolli
Member
Posts: 133
Joined: Mon Jan 15, 2018 21:46
GitHub: HeyITGuyFixIt
IRC: CSirolli
In-game: CSirolli
Location: Florida, USA
Contact:

Re: Problem with registration of node.

by csirolli » Post

I don't know about the actual node generation, but somehow use image overlays. For example, have the basic block, and overlay it with colors, and further overlay it with basic shapes, letters, punctuation, etc.

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests