A nodebox is just a box-shaped object within a node. Normally you include a few of them in your node to create the basic shape. First, imagine a square:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Now, mentally mark the bottom left corner:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
This square is the front face of your nodebox, so it covers the X and Y dimensions Now extend the box into a 3d cube, i.e. the Z direction:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
And mentally mark the diagonally-opposite corner at the back side of the cube:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
The dead center of the box is {0,0,0}. The left, bottom, and front-most sides of the box are the -X, -Y, and -Z sides, respectively. Any given direction extends from -0.5 to +0.5 (which is why 0 is in the middle). You can go past -/+ 0.5 if you want, but that'll cause it to encroach into neighboring nodes (Home Decor refrigerator does that), and textures may or may not tile properly, so stick to within those limits for now.
The format of a nodebox definition is {X1, Y1, Z1, X2, Y2, Z2} for corners 1 and 2 as described above.
So, you set the drawtype to "nodebox", then you include one or more of the above {X1,..Z2} bits above, for every piece you want to define, in this format:
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('mymod:my_best_nodebox', {
description = "My kickass nodebox object",
tiles = {
"top.jpg",
"bottom.jpg",
"left.jpg",
"right.jpg",
"front.jpg",
"back.jpg",
},
-- [more of the usual register_node() stuff here]
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{X1, Y1, Z1, X2, Y2, Z2},
{X1, Y1, Z1, X2, Y2, Z2},
{X1, Y1, Z1, X2, Y2, Z2},
{X1, Y1, Z1, X2, Y2, Z2},
-- for as many boxes as you want to include
}
},
})
The images you supply in the tiles parameter will effectively be projected onto the nodeboxes after they're created, so each face of a nodebox will receive the pixels from your image that would be at that location had this just been a normal, whole 1x1x1 cube. This is true for every nodebox you supply, even if it seems like one should cast a shadow on another, so you'll want to stick with solid objects or use textures that can apply equally well to all nodebox faces that point in a given direction. This is why the valves in Pipeworks have a shadow under the handle - because the texture is repeated onto the nodeboxes below the handle as well.
Essentially, it's the same format as a selection box, and typically, you'll want to include such a section in the node def as well, with suitable box dimensions, so that the user doesn't have to select the entire cube just for some tiny little object inside it.
Also, thou shalt worship my mad ASCII art skillz. ;-)