WoW:API tContains and WoW:API CanCooperateWithToon: Difference between pages

From AddOn Studio
(Difference between pages)
Jump to navigation Jump to search
(Missing end; fixed a syntax error.)
 
(Created page with '{{framexmlfunc|FrameXML/FriendsFrame.lua}} __NOTOC__ Determines if the player can cooperate with another player character CanCooperateWithToon(toonID); == Arguments == ;toon…')
 
Line 1: Line 1:
{{luaapi}} __NOTOC__
{{framexmlfunc|FrameXML/FriendsFrame.lua}} __NOTOC__
Determines if the player can cooperate with another player character
canCooperate = CanCooperateWithToon(toonID);


tContains(table, value)


Returns true (1) if value is in table, false (nil) otherwise. Note: this is not a standard Lua function, but was added by Blizzard to simplify table searches.


== Arguments ==


<big>'''Implementation'''</big>
;toonID : number - determined from the 5th return of [[API BNGetFriendInfo|BNGetFriendInfo]](friendIndex)
function tContains(table, item)
        local index = 1;
        while table[index] do
                if ( item == table[index] ) then
                        return 1;
                end
                index = index + 1;
        end
        return nil;
end




== Example ==
== Returns ==


banana = { "yellow", "curved", "yummy" };
;canCooperate : boolean - true if and only if the toon represented by the toonID is on the same realm and faction as the player
lotus = { "pink", "pretty" };
 
eatme = tContains( lotus, "yummy" );
 
<big>'''Result'''</big>
eatme = false

Revision as of 20:05, 6 July 2010

WoW API < CanCooperateWithToon

"I" iconThis function is implemented in Lua here FrameXML/FriendsFrame.lua.

Determines if the player can cooperate with another player character

canCooperate = CanCooperateWithToon(toonID);


Arguments

toonID
number - determined from the 5th return of BNGetFriendInfo(friendIndex)


Returns

canCooperate
boolean - true if and only if the toon represented by the toonID is on the same realm and faction as the player