• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved get/has attributes doesn't seem to be working. TFS 1.2/3

Codex NG

Recurrent Flamer
Joined
Jul 24, 2015
Messages
2,994
Solutions
12
Reaction score
1,657
I ran a for loop over all the attributes on a target.
Lua:
 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
 
Last edited:
These are the results of that for loop
Code:
The Forgotten Server - Version 1.3
Compiled with GNU C++ version 5.4.0 20160609
Compiled on May 23 2017 05:48:06 for platform x64

A server developed by Mark Samman
Visit our forum for updates, support, and resources: http://otland.net/.

>> Loading config
>> Establishing database connection... MySQL 5.7.18
>> Running database manager
>> Loading vocations
>> Loading items
>> Loading script systems
>> Loading monsters
>> Loading outfits
>> Checking world type... PVP
>> Loading map
> Map size: 2048x2048.
> Map loading time: 0.814 seconds.
> Loaded house items in: 0.001 s
>> Initializing gamestate
>> Loaded all modules, server starting up...
>> Forgotten Server Online!

God has logged in.
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
SIGINT received, shutting game server down...
God has logged out.
Saving server...
> Saved house items in: 0.15 s
Shutting down... done!
 
I mark solved because much like most of the metamethods in TFS get & has attributes are misleading metamethods, they will not work on an item directly unless that item has had setAttribute used already on it. Which makes both those methods rather useless.

Yes there are metamethods which can be applied to an item via itemType however set/get/has should be labeled as custom not as a general term, maybe its a language barrier (english being a complex language) because in english there are many ways to describe something than in other languages.. I won't hold this against you guys ;)
 
Back
Top