mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Allow nodes to specify which sides to connect to.
NDT_CONNECTED attempts to connect to any side of nodes that it can connect to, which is troublesome for FACEDIR type nodes that generally may only have one usable face, and can be rotated. We introduce a node parameter `connect_sides` that is valid for any node type. If specified, it lists faces of the node (in "top", "bottom", "front", "left", "back", "right", form, as array) that connecting nodeboxes can connect to. "front" corresponds to the south facing side of a node with facedir = 0. If the node is rotatable using *simple* FACEDIR, then the attached face is properly rotated before checking. This allows e.g. a chest to be attached to only from the rear side.
This commit is contained in:
parent
e737b1c271
commit
37b4f0d34c
6 changed files with 58 additions and 5 deletions
|
@ -547,6 +547,34 @@ ContentFeatures read_content_features(lua_State *L, int index)
|
|||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, index, "connect_sides");
|
||||
if (lua_istable(L, -1)) {
|
||||
int table = lua_gettop(L);
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, table) != 0) {
|
||||
// Value at -1
|
||||
std::string side(lua_tostring(L, -1));
|
||||
// Note faces are flipped to make checking easier
|
||||
if (side == "top")
|
||||
f.connect_sides |= 2;
|
||||
else if (side == "bottom")
|
||||
f.connect_sides |= 1;
|
||||
else if (side == "front")
|
||||
f.connect_sides |= 16;
|
||||
else if (side == "left")
|
||||
f.connect_sides |= 32;
|
||||
else if (side == "back")
|
||||
f.connect_sides |= 4;
|
||||
else if (side == "right")
|
||||
f.connect_sides |= 8;
|
||||
else
|
||||
warningstream << "Unknown value for \"connect_sides\": "
|
||||
<< side << std::endl;
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, index, "selection_box");
|
||||
if(lua_istable(L, -1))
|
||||
f.selection_box = read_nodebox(L, -1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue