mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add wear bar color API (#13328)
--------- Co-authored-by: Muhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com> Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com> Co-authored-by: grorp <gregor.parzefall@posteo.de>
This commit is contained in:
parent
e10d8080ba
commit
176e674a51
19 changed files with 598 additions and 26 deletions
|
@ -376,6 +376,22 @@ int LuaItemStack::l_add_wear_by_uses(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
// get_wear_bar_params(self) -> table
|
||||
// Returns the effective wear bar parameters.
|
||||
// Returns nil if this item has none associated.
|
||||
int LuaItemStack::l_get_wear_bar_params(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
LuaItemStack *o = checkObject<LuaItemStack>(L, 1);
|
||||
ItemStack &item = o->m_stack;
|
||||
auto params = item.getWearBarParams(getGameDef(L)->idef());
|
||||
if (params.has_value()) {
|
||||
push_wear_bar_params(L, *params);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// add_item(self, itemstack or itemstring or table or nil) -> itemstack
|
||||
// Returns leftover item stack
|
||||
int LuaItemStack::l_add_item(lua_State *L)
|
||||
|
@ -551,6 +567,7 @@ const luaL_Reg LuaItemStack::methods[] = {
|
|||
luamethod(LuaItemStack, get_tool_capabilities),
|
||||
luamethod(LuaItemStack, add_wear),
|
||||
luamethod(LuaItemStack, add_wear_by_uses),
|
||||
luamethod(LuaItemStack, get_wear_bar_params),
|
||||
luamethod(LuaItemStack, add_item),
|
||||
luamethod(LuaItemStack, item_fits),
|
||||
luamethod(LuaItemStack, take_item),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue