BloodGauntlet
Member
- Joined
- Jul 27, 2016
- Messages
- 45
- Reaction score
- 18
This always returns zero no matter the weapon equipped. Am I doing something wrong or is this a bug?
Here is the getAttribute function from lua.cpp, the source is unmodified. I'm just posting this for reference.
Code:
function foo (player)
local weapon = player:getSlotItem(CONST_SLOT_LEFT)
local damage = weapon:getAttribute(ITEM_ATTRIBUTE_ATTACK)
return damage
end
Here is the getAttribute function from lua.cpp, the source is unmodified. I'm just posting this for reference.
Code:
int LuaScriptInterface::luaItemGetAttribute(lua_State* L)
{
// item:getAttribute(key)
Item* item = getUserdata<Item>(L, 1);
if (!item) {
lua_pushnil(L);
return 1;
}
itemAttrTypes attribute;
if (isNumber(L, 2)) {
attribute = getNumber<itemAttrTypes>(L, 2);
} else if (isString(L, 2)) {
attribute = stringToItemAttribute(getString(L, 2));
} else {
attribute = ITEM_ATTRIBUTE_NONE;
}
if (ItemAttributes::isIntAttrType(attribute)) {
lua_pushnumber(L, item->getIntAttr(attribute));
} else if (ItemAttributes::isStrAttrType(attribute)) {
pushString(L, item->getStrAttr(attribute));
} else {
lua_pushnil(L);
}
return 1;
}
Last edited: