mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Hardware coloring for itemstacks
Adds the possibility to colorize item stacks based on their metadata. In the item/node definition you can specify palette (an image file) and color (fallback color if the item has no palette or metadata). Then you can add palette_index to the metadata. Dropped itemstacks with different colors do not merge.
This commit is contained in:
parent
d4e9dd4643
commit
58d83a7bb2
23 changed files with 308 additions and 139 deletions
|
@ -58,6 +58,12 @@ ItemDefinition read_item_definition(lua_State* L,int index,
|
|||
getstringfield(L, index, "description", def.description);
|
||||
getstringfield(L, index, "inventory_image", def.inventory_image);
|
||||
getstringfield(L, index, "wield_image", def.wield_image);
|
||||
getstringfield(L, index, "palette", def.palette_image);
|
||||
|
||||
// Read item color.
|
||||
lua_getfield(L, index, "color");
|
||||
read_color(L, -1, &def.color);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, index, "wield_scale");
|
||||
if(lua_istable(L, -1)){
|
||||
|
@ -118,7 +124,7 @@ ItemDefinition read_item_definition(lua_State* L,int index,
|
|||
|
||||
/******************************************************************************/
|
||||
void read_object_properties(lua_State *L, int index,
|
||||
ObjectProperties *prop)
|
||||
ObjectProperties *prop, IItemDefManager *idef)
|
||||
{
|
||||
if(index < 0)
|
||||
index = lua_gettop(L) + 1 + index;
|
||||
|
@ -216,6 +222,10 @@ void read_object_properties(lua_State *L, int index,
|
|||
}
|
||||
lua_pop(L, 1);
|
||||
getstringfield(L, -1, "infotext", prop->infotext);
|
||||
lua_getfield(L, -1, "wield_item");
|
||||
if (!lua_isnil(L, -1))
|
||||
prop->wield_item = read_item(L, -1, idef).getItemString();
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -284,6 +294,8 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
|
|||
lua_setfield(L, -2, "automatic_face_movement_max_rotation_per_sec");
|
||||
lua_pushlstring(L, prop->infotext.c_str(), prop->infotext.size());
|
||||
lua_setfield(L, -2, "infotext");
|
||||
lua_pushlstring(L, prop->wield_item.c_str(), prop->wield_item.size());
|
||||
lua_setfield(L, -2, "wield_item");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -89,7 +89,8 @@ void push_tool_capabilities (lua_State *L,
|
|||
ItemDefinition read_item_definition (lua_State *L, int index,
|
||||
ItemDefinition default_def);
|
||||
void read_object_properties (lua_State *L, int index,
|
||||
ObjectProperties *prop);
|
||||
ObjectProperties *prop,
|
||||
IItemDefManager *idef);
|
||||
void push_object_properties (lua_State *L,
|
||||
ObjectProperties *prop);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue