Acedayz
Member
- Joined
- Jan 24, 2015
- Messages
- 38
- Reaction score
- 19
What I've had trouble with is this:
So I tried to figure out why my attributes wouldn't work, and this what I've done:
Found out the values:
0x7FFE13 = 8388115
0x1EC = 492
Looked at the last attribute value: (unchanged)
ITEM_ATTRIBUTE_DOORID = 4194304
4194304 * 2 = 8388608
8388608 - 492 = 8388116
8388116 - 1 = 0x7FFE13
So what I did was to take my last custom attribute's value:
ITEM_ATTRIBUTE_TEST9 = 2147483648
And did the same math as above which gave me the value 0xFFFFFE13.
So I changed it to this:
This made item:getAttribute(ITEM_ATTRIBUTE_TEST9) work, but not my item:getTest9() function.
Which makes me think the next problem is with this function:
I can't figure out where the number 492(0x1EC) is coming from, so this is where I'd like some help.
getTest9() works for getting the value of the item type, but not the item attribute.
I may be doing this completely wrong and would like some help to actually understand what these functions does.
Thank you!
EDIT:
Ok, nevermind.
There were no more problems with those functions, just another little mistake as usual.
Code:
inline static bool isIntAttrType(itemAttrTypes type) {
return (type & 0x7FFE13) != 0;
}
inline static bool isStrAttrType(itemAttrTypes type) {
return (type & 0x1EC) != 0;
}
So I tried to figure out why my attributes wouldn't work, and this what I've done:
Found out the values:
0x7FFE13 = 8388115
0x1EC = 492
Looked at the last attribute value: (unchanged)
ITEM_ATTRIBUTE_DOORID = 4194304
4194304 * 2 = 8388608
8388608 - 492 = 8388116
8388116 - 1 = 0x7FFE13
So what I did was to take my last custom attribute's value:
ITEM_ATTRIBUTE_TEST9 = 2147483648
And did the same math as above which gave me the value 0xFFFFFE13.
So I changed it to this:
Code:
inline static bool isIntAttrType(itemAttrTypes type) {
return (type & 0xFFFFFE13) != 0;
}
This made item:getAttribute(ITEM_ATTRIBUTE_TEST9) work, but not my item:getTest9() function.
Code:
int32_t LuaScriptInterface::luaItemGetTest9(lua_State* L)
{
// item:getTest9()
Item* item = getUserdata<Item>(L, 1);
if (item) {
lua_pushnumber(L, item->getTest9());
}
else {
lua_pushnil(L);
}
return 1;
}
Code:
int8_t getTest9() const {
if (hasAttribute(ITEM_ATTRIBUTE_TEST9)) {
return getIntAttr(ITEM_ATTRIBUTE_TEST9);
}
return items[id].test9;
}
Which makes me think the next problem is with this function:
Code:
inline static bool isStrAttrType(itemAttrTypes type) {
return (type & 0x1EC) != 0;
}
I can't figure out where the number 492(0x1EC) is coming from, so this is where I'd like some help.
getTest9() works for getting the value of the item type, but not the item attribute.
I may be doing this completely wrong and would like some help to actually understand what these functions does.
Thank you!
EDIT:
Ok, nevermind.
There were no more problems with those functions, just another little mistake as usual.
Last edited: