1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-14 09:05:19 +02:00

CAO 'node' visual (#15683)

This commit is contained in:
sfan5
2025-01-14 20:25:52 +01:00
parent 5a8720a484
commit 27bbe3a873
14 changed files with 267 additions and 91 deletions

View File

@@ -294,11 +294,13 @@ const std::array<const char *, 33> object_property_keys = {
"shaded",
"damage_texture_modifier",
"show_on_minimap",
// "node" is intentionally not here as it's gated behind `fallback` below!
};
/******************************************************************************/
void read_object_properties(lua_State *L, int index,
ServerActiveObject *sao, ObjectProperties *prop, IItemDefManager *idef)
ServerActiveObject *sao, ObjectProperties *prop, IItemDefManager *idef,
bool fallback)
{
if(index < 0)
index = lua_gettop(L) + 1 + index;
@@ -399,6 +401,16 @@ void read_object_properties(lua_State *L, int index,
}
lua_pop(L, 1);
// This hack exists because the name 'node' easily collides with mods own
// usage (or in this case literally builtin/game/falling.lua).
if (!fallback) {
lua_getfield(L, -1, "node");
if (lua_istable(L, -1)) {
prop->node = readnode(L, -1);
}
lua_pop(L, 1);
}
lua_getfield(L, -1, "spritediv");
if(lua_istable(L, -1))
prop->spritediv = read_v2s16(L, -1);
@@ -513,6 +525,8 @@ void push_object_properties(lua_State *L, const ObjectProperties *prop)
}
lua_setfield(L, -2, "colors");
pushnode(L, prop->node);
lua_setfield(L, -2, "node");
push_v2s16(L, prop->spritediv);
lua_setfield(L, -2, "spritediv");
push_v2s16(L, prop->initial_sprite_basepos);