[Solved] Connected NodeBox DrawType

Post Reply
User avatar
domtron vox
Member
Posts: 111
Joined: Thu Feb 20, 2014 21:07
GitHub: DomtronVox
IRC: Domtron
In-game: Domtron

[Solved] Connected NodeBox DrawType

by domtron vox » Post

So I just spent 10-20 minutes trying to find documentation on the connected nodebox drawtype to figure out why it wasn't working. It was a fairly "duh" moment, but I was surprised that I didn't see any documentation on it other then in the Lua_api.txt and that was obscure enough that I missed the answer. I didn't find anything on the wiki or the forums. So I'll post this for any lost soul looking for the same info and add it to the wiki when I get time. (or if I forget and look for the info again)

The nodebox drawtype has a subtype called "connected" which allows a single node definition to connect to it's neighbors visually. You define a normal nodebox for the "fixed" portion which is the default look if the nodebox has no valid nodes that it can connect to. You can then define additional nodeboxes, that get added to the fixed one, for each of 6 directions that there is a valid block. Any of these can be left off without causng errors; the block will just not react when a valid block is in that direction.

(this is what I missed) To define what a valid connecting block is you must define the "connected_to" table and add a list of full block names. (mod_name:block_name)

here is a quick example (not tested, made changes from what I was testing so generally it should be right)

Code: Select all

minetest.register_node("frame:frame2", {
    description = "Spacestation Frame",
    paramtype = "light",
    drop = "frame:frame2",
    --These 3 are needed for it to work
    drawtype = "nodebox",
    node_box = {
        type           ="connected",
        --default look with no valid connectable ajacent nodes
        fixed          = frame.frame_nodebox.frame_fixed,
        --You can leave out any of the following and it should still work it just will not connect in that direction.
        connect_top    = frame.frame_nodebox.frame_top_connect,
        connect_bottom = frame.frame_nodebox.frame_bottom_connect,
        connect_front  = frame.frame_nodebox.frame_front_connect,
        connect_left   = frame.frame_nodebox.frame_left_connect,
        connect_back   =frame.frame_nodebox.frame_back_connect,
        connect_right  = frame.frame_nodebox.frame_right_connect
    },
    connects_to = { "frame:frame2" },  --needed to know what blocks are valid connectable blocks. Without it none of the extra nodeboxes will be used
})
Sorry this was a quick and dirty post. I'll try to clean it up later and maybe add it to the wiki as well.

User avatar
Rotfuchs-von-Vulpes
New member
Posts: 7
Joined: Sat Apr 23, 2022 17:32
GitHub: Rotfuchs-von-Vulpes
In-game: Rotfuchs-von-Vulpes
Location: Mato Grosso do Sul, Brasil
Contact:

Re: [Solved] Connected NodeBox DrawType

by Rotfuchs-von-Vulpes » Post

YOU SAVE ME BRO

Code: Select all

minetest.register_node('cell_machines:pipe', {
	description = 'Pipe',
	tiles = {'default_bronze_block.png'},
	drawtype = 'nodebox',
	node_box = {
		type = 'connected',
		fixed = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
		connect_top = {-0.1, 0.1, -0.1, 0.1, 0.5, 0.1},
		connect_bottom = {-0.1, -0.1, -0.1, 0.1, -0.5, 0.1},
		connect_front = {-0.1, -0.1, -0.1, 0.1, 0.1, -0.5},
		connect_left = {-0.1, -0.1, -0.1, -0.5, 0.1, 0.1},
		connect_back = {-0.1, -0.1, 0.1, 0.1, 0.1, 0.5},
		connect_right = {0.1, -0.1, -0.1, 0.5, 0.1, 0.1},
	},
	connects_to = {'cell_machines:pipe'},
	paramtype = 'light',
	groups = {choppy=3, stone=1},
	drop = 'cell_machines:pipe',
})
Attachments
connected.png
connected.png (300.7 KiB) Viewed 361 times

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests