creating non-cubic nodes tutorial

User avatar
12Me21
Member
 
Posts: 826
Joined: Tue Mar 05, 2013 00:36

creating non-cubic nodes tutorial

by 12Me21 » Tue Apr 02, 2013 14:19

I haven't seen a lot of mods that have non-cubic nodes, so it seems like a lot of people don't know how to make non-cubic nodes. That's why I made this tutorial.

This assumes that you know how to add new nodes, and that you understand how to code stuff.

Example:
(This is the code for the leaves in my minitrees mod)

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_node('minitrees:leaves', {
    description =("Mini Leaves"),
    drawtype = "nodebox",
    tiles = {
        'leaves.png',
    },
        selection_box = {
                type = "fixed",
                fixed = { -1/3, -1/3, -1/3, 1/3, 1/3, 1/3 }
        },
        node_box = {
            type = "fixed",
            fixed = {
                { -1/3, -0.5, -1/3, 1/3, 0.5, 1/3 },
                { -0.5, -1/3, -1/3, -1/3, 1/3, 1/3 },
                { 1/3, -1/3, -1/3, 0.5, 1/3, 1/3 },
                { -1/3, -1/3, 1/3, 1/3, 1/3, 0.5 },
                { -1/3, -1/3, -0.5, 1/3, 1/3, -1/3 },
            },
        },

    sunlight_propagates = true,
    paramtype = "light",
    walkable = true,
    groups = { snappy = 3, choppy = 3  },
    sounds = default.node_sound_wood_defaults(),
})


All nodes have to be made of one rectangular prism or multiple rectanglular prisms.
This is the part that makes the shape of it:
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
        selection_box = {
                type = "fixed",
                fixed = { -1/3, -1/3, -1/3, 1/3, 1/3, 1/3 }
        },
        node_box = {
            type = "fixed",
            fixed = {
                { -1/3, -0.5, -1/3, 1/3, 0.5, 1/3 },
                { -0.5, -1/3, -1/3, -1/3, 1/3, 1/3 },
                { 1/3, -1/3, -1/3, 0.5, 1/3, 1/3 },
                { -1/3, -1/3, 1/3, 1/3, 1/3, 0.5 },
                { -1/3, -1/3, -0.5, 1/3, 1/3, -1/3 },
            },
        },


Each line of numbers stands for each rectangular prism in the node. The numbers in each line stand for (in this order):
{ -x, -y, -z, x, y, z }
or, more simply:
{ left side, bottom, back, right side, top, front }
They are measured from the middle of the nodebox (0), and the edge of the nodebox is 0.5 or 1/2 (one half)
If the middle of the nodebox is inside the node, then the first 3 coordinates will be negitive, and the last 3 will be positive.
Here is a picture:
Image
You can use as many rectangular prisms as you want, but it is better to use fewer.
This is a signature virus. Add me to your signature so that I can multiply.
Don't ever save anything as a JPEG.
 

User avatar
Likwid H-Craft
Member
 
Posts: 1113
Joined: Sun Jan 06, 2013 14:20

by Likwid H-Craft » Tue Apr 02, 2013 14:24

Thank you 12Me21 Since I sometimes lost on the numbers this made it more, better understanding but what make it better if you added the xyz into the code just in case someone don't get it...
My Domain's/others:
http://likwidtest.hj.cx/ (Not Done)
 


Return to Minetest General

Who is online

Users browsing this forum: Bing [Bot] and 15 guests