Add methods item:SetRandomProperties and item:SetRandomSuffix (#274)

This commit is contained in:
Clément
2025-08-10 11:54:29 +01:00
committed by GitHub
parent 4d44b6749d
commit 2deb507952
2 changed files with 28 additions and 0 deletions

View File

@@ -927,6 +927,8 @@ ElunaRegister<Item> ItemMethods[] =
{ "SetOwner", &LuaItem::SetOwner }, { "SetOwner", &LuaItem::SetOwner },
{ "SetBinding", &LuaItem::SetBinding }, { "SetBinding", &LuaItem::SetBinding },
{ "SetCount", &LuaItem::SetCount }, { "SetCount", &LuaItem::SetCount },
{ "SetRandomProperty", &LuaItem::SetRandomProperty },
{ "SetRandomSuffix", &LuaItem::SetRandomSuffix },
// Boolean // Boolean
{ "IsSoulBound", &LuaItem::IsSoulBound }, { "IsSoulBound", &LuaItem::IsSoulBound },

View File

@@ -683,6 +683,32 @@ namespace LuaItem
return 1; return 1;
} }
/**
* Sets the random properties for the [Item] from a given random property ID.
*
* @param uint32 randomPropId : The ID of the random property to be applied.
*/
int SetRandomProperty(lua_State* L, Item* item)
{
uint32 randomPropId = Eluna::CHECKVAL<uint32>(L, 2);
item->SetItemRandomProperties(randomPropId);
return 0;
}
/**
* Sets the random suffix for the [Item] from a given random suffix ID.
*
* @param uint32 randomSuffixId : The ID of the random suffix to be applied.
*/
int SetRandomSuffix(lua_State* L, Item* item)
{
uint32 randomPropId = Eluna::CHECKVAL<uint32>(L, 2);
item->SetItemRandomProperties(-randomPropId);
return 0;
}
/* OTHER */ /* OTHER */
/** /**
* Removes an enchant from the [Item] by the specified slot * Removes an enchant from the [Item] by the specified slot