[Solved] Connected NodeBox DrawType

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

[Solved] Connected NodeBox DrawType

by domtron vox » Wed Jun 29, 2016 14:36

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.

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 5 guests