I posted this in the support section on the regular boards in the hopes that someone has encounter this issue before, however all I got were a lot of views and not 1 response. Then I posted it on the premium boards and Ninja responded with a smart ass answer... then he changed his response to something more desirable.
But in the end he was no help on the issue as it was clear he really didn't care about helping.
To the issue, I ran a for loop over a target item in an onUse script, when I click on the target it gets the name, the itemid but not any of the attributes, all the values returned are either false for hasAttribute or 0, an empty string, nil for getAttribute.
local x = {
ITEM_ATTRIBUTE_NONE,
ITEM_ATTRIBUTE_ACTIONID ,
ITEM_ATTRIBUTE_UNIQUEID ,
ITEM_ATTRIBUTE_DESCRIPTION ,
ITEM_ATTRIBUTE_TEXT ,
ITEM_ATTRIBUTE_DATE ,
ITEM_ATTRIBUTE_WRITER ,
ITEM_ATTRIBUTE_NAME ,
ITEM_ATTRIBUTE_ARTICLE ,
ITEM_ATTRIBUTE_PLURALNAME,
ITEM_ATTRIBUTE_WEIGHT,
ITEM_ATTRIBUTE_ATTACK ,
ITEM_ATTRIBUTE_DEFENSE ,
ITEM_ATTRIBUTE_EXTRADEFENSE,
ITEM_ATTRIBUTE_ARMOR,
ITEM_ATTRIBUTE_HITCHANCE,
ITEM_ATTRIBUTE_SHOOTRANGE,
ITEM_ATTRIBUTE_OWNER,
ITEM_ATTRIBUTE_DURATION,
ITEM_ATTRIBUTE_DECAYSTATE ,
ITEM_ATTRIBUTE_CORPSEOWNER,
ITEM_ATTRIBUTE_CHARGES ,
ITEM_ATTRIBUTE_FLUIDTYPE,
ITEM_ATTRIBUTE_DOORID ,
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if target then
for i = 1, #x do
print(target:getName(), target:getId(), target:hasAttribute(x[i]), target:getAttribute(x[i]))
end
end
return true
end
And here is the results
knight armor 2476 false nil
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false
knight armor 2476 false
knight armor 2476 false 0
knight armor 2476 false
knight armor 2476 false
knight armor 2476 false
knight armor 2476 false
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false 0
knight armor 2476 false 0
club 2382 false nil
club 2382 false 0
club 2382 false 0
club 2382 false
club 2382 false
club 2382 false 0
club 2382 false
club 2382 false
club 2382 false
club 2382 false
club 2382 false 0
club 2382 false 0
club 2382 false 0
club 2382 false 0
club 2382 false 0
club 2382 false 0
club 2382 false 0
club 2382 false 0
club 2382 false 0
club 2382 false 0
club 2382 false 0
club 2382 false 0
club 2382 false 0
club 2382 false 0
I then changed the code to reflect a suggestion someone gave me.
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if target then
target:setAttribute(ITEM_ATTRIBUTE_ARMOR, 1)
print(target:getName(), target:getId(), target:hasAttribute("armor"), target:getAttribute("armor"))
end
return true
end
and this is the results of that test
brass helmet 2460 false 0 -- this is before i set the attribute
club 2382 false 0
knight armor 2476 false 0
brass helmet 2460 true 1 -- and this is after
This is what the items look like
You see a brass helmet (Arm:3).
It weighs 27.00 oz.
Item ID: 2460
Position: 95, 114, 7
You see a brass helmet (Arm:1).
It weighs 27.00 oz.
Item ID: 2460
Position: 95, 114, 7
Use ItemType(itemId) to get the original attributes
Ex:
ItemType(itemId):gerArmor()
:getAttribute() is only for custom attributes
Please use OTLand Supoort board next time.
Please read what I wrote next time before you tell me to use OTLand Support
Can you print out each index in x and make sure they're equal to the values here: https://github.com/otland/forgottenserver/blob/eeacf88c1139d9eb9924e77b8e31deb02c284d41/src/enums.h#L36
Perhaps the values aren't correct. That would explain why target:hasAttribute("armor") works, but not target:hasAttribute(x[i]).
Please read what I wrote next time before you tell me to use OTLand Support
so next time don't erase issue template, who is watching this repository want to hear about the issue not your forums adventures.
@wgrriffel In my original post I am showing how I've exhausted other possibilities to find a solution or possibly get a more in depth explanation on how these methods are used from either the staff or the support team, but clearly its either A they know less than me or B they just don't care to help anyone that they aren't friends with.
Soo why don't you stfu, I got one guy telling me to use support boards (when he clearly has not read what I posted) and now I got you telling me you don't want to hear about my "forum adventures",
Well too bad you people need to get your heads out of your own asses and pay attention, because the code does not get fixed if no one reports on its behavior (expected or otherwise).
And if the majority of the people in this TFS community weren't soo god dam lazy then maybe we would have proper documentation by now. I've probably have written more documentation on TFS then the people who collectively wrote the code.
Soo why don't you stfu, I got one guy telling me to use support boards (when he clearly has not read what I posted) and now I got you telling me you don't want to hear about my "forum adventures",
if you had filled issue template instead of erasing it wouldn't had happened, because we could clarity see supposed problem without having to read your wall of text.
And if the majority of the people in this TFS community weren't soo god dam lazy then maybe we would have proper documentation by now. I've probably have written more documentation on TFS then the people who collectively wrote the code.
if you have time to do so why don't you did it? i believe that you are the only one 'god dam' lazy here.
this kind of comment coming from you doesn't surprise me at all, blocking you from github to prevent further spamming messages in my email, hopefully someone block you from this repository once again https://github.com/otland/forgottenserver/issues/1772#issuecomment-242510968.
The attribute functions seem to work perfectly as intended and as expected. I believe this can be closed.
hasAttribute/ getAttribute only work for custom attributes, @conde2 is right.
See https://github.com/otland/forgottenserver/blob/225c2aa637e51fed2c6636e6cbe7ca25b44d6e50/src/luascript.cpp#L5964-L5973