mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
CAO 'node' visual (#15683)
This commit is contained in:
parent
5a8720a484
commit
27bbe3a873
14 changed files with 267 additions and 91 deletions
|
@ -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);
|
||||
|
|
|
@ -99,10 +99,10 @@ void read_item_definition(lua_State *L, int index,
|
|||
void push_item_definition(lua_State *L, const ItemDefinition &i);
|
||||
void push_item_definition_full(lua_State *L, const ItemDefinition &i);
|
||||
|
||||
/// @param fallback set to true if reading from bare entity table (not initial_properties)
|
||||
void read_object_properties(lua_State *L, int index,
|
||||
ServerActiveObject *sao,
|
||||
ObjectProperties *prop,
|
||||
IItemDefManager *idef);
|
||||
ServerActiveObject *sao, ObjectProperties *prop,
|
||||
IItemDefManager *idef, bool fallback = false);
|
||||
|
||||
void push_object_properties(lua_State *L, const ObjectProperties *prop);
|
||||
|
||||
|
|
|
@ -197,13 +197,17 @@ void ScriptApiEntity::luaentity_GetProperties(u16 id,
|
|||
// Set default values that differ from ObjectProperties defaults
|
||||
prop->hp_max = 10;
|
||||
|
||||
auto *idef = getServer()->idef();
|
||||
|
||||
// Deprecated: read object properties directly
|
||||
// TODO: this should be changed to not read the legacy place
|
||||
// if `initial_properties` exists!
|
||||
logDeprecationForExistingProperties(L, -1, entity_name);
|
||||
read_object_properties(L, -1, self, prop, getServer()->idef());
|
||||
read_object_properties(L, -1, self, prop, idef, true);
|
||||
|
||||
// Read initial_properties
|
||||
lua_getfield(L, -1, "initial_properties");
|
||||
read_object_properties(L, -1, self, prop, getServer()->idef());
|
||||
read_object_properties(L, -1, self, prop, idef);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue