API
API
:GetSetTable("setname")
Returns a table with the contents of the requested set.
Args
- "setname"
- string - The name of a set within PT3
Returns
table -
- if this is a multiset: a list ordered table of this multiset's member tables.
- if this is not a multiset: the index of each table member is the itemid, and the value of each member is the value of that itemid in the set (or true if the item has no attached value). Also contains the field .set, which is the set's name.
Remarks
Use this function if you need to display a list of items in a set or something similar.
Example
PT:GetSetTable("Reagent.Ammo")
:GetSetStringCompressed("setname")
Returns the set data that PT3 has for a given set, without uncompressing it into a useable form. Will also autogenerate the correct strings for virtual children (which are implied in "c[]" sets) or virtual parents (which are implied in the data hierarchy).
Args
- "setname"
- string - The name of a set within PT3
Returns
string - The compressed set string for this set.
Remarks
A quick and simple function for checking the state of a set. Good for keeping an eye on a dynamic custom set.
Example
PT:GetSetStringCompressed("MyAddon.DataB")
:GetSetStringUncompressed("setname")
Returns the set data that PT3 has for a given set, uncompressed into a usable form. Will also autogenerate the correct strings for virtual children (which are implied in "c[]" sets) or virtual parents (which are implied in the data hierarchy).
Args
- "setname"
- string - The name of a set within PT3
Returns
string - The uncompressed set string for this set.
Remarks
A quick and simple function for checking the state of a set. Good for keeping an eye on a dynamic custom set.
Example
PT:GetSetStringUncompressed("MyAddon.DataE")
:ItemInSet(item, "setname")
Find if an item is contained within a set.
Args
- item
- string or number - The itemid or itemlink of an item
- "setname"
- string - The name of a set within PT3
Returns
string - the value of this item within the given set.
string - the set that this item was found within.
Example
PT:ItemInSet(24468, "Tradeskill.Crafted")
:AddData("name", arg2[, arg3])
Add custom data to PeriodicTable-3.0
Args
- "name"
- string - The name of the set or module you're importing
- arg2
- string or table - The contents of the set's string -or- the table of the module -or- the module's version string
- arg3
- table - The module's data contents (if you provided a version number)
Remarks
Add data to PT3. Note that you can use this function to overwrite data that's already present, if, for example, a custom set gets changed.
Example
PT:AddData("MyAddon.SetA", "u,11436:Moose,7521:Sock") PT:AddData("MyAddon", {["MyAddon.SetA"] = "u,11436:Moose,7521:Sock", ["MyAddon.SetB"] = "5132,25443",}) PT:AddData("MyAddon", "$Rev: 23470 $" ,{["MyAddon.SetA"] = "u,11436:Moose,7521:Sock", ["MyAddon.SetB"] = "5132,25443"})
:ItemSearch(item)
Search for an item in the PT3 data library.
Args
- item
- string or number - itemid or itemlink
Returns
table - a table of all the sets this item is a member of.
Remarks
This sucker is slow and heavy. It takes about 0.12 seconds for me at the moment. And it needs to uncompress -all- the set's data. The bad news is that this eats a ton of memory, the good news is that it can be reclaimed by the GC directly afterward. I'd suggest only using this when requested by the user, and then running collectgarbage() right afterward. If you must run this automatically, cache the results.
Example
PT:ItemSearch(14373)
:GetNumSets()
Returns the number of sets currently in the PT3 set library. Note that "c[]" style sets will take up more spots after being requested, so don't be alarmed if this number grows during operation.
Returns
number - the number of sets.
Remarks
Just kinda a 'toy' function for statistical purposes.
Example
PT:GetNumSets()
:GetNumCachedSets()
Returns the number of set tables currently in the PT3 cache.
Returns
number - the number of sets.
Remarks
Just kinda a 'toy' function for statistical purposes.
Example
PT:GetNumCachedSets()
:GetBetter("setname",itema,itemb)
Return which one of the items has the higher value.
Args
- "setname"
- string - PT3 set name
- itema
- string or number - itemid or itemlink
- itemb
- string or number - itemid or itemlink
Returns
number - the itemid of the higher valued item.
Example
PT:GetBetter("Rep.Rewards",13221,32002)
:GetBest("setname")
Get the highest valued item in this set.
Args
- "setname"
- string - PT3 set name
Returns
number - the itemid of the highest valued item
number - the value of the highest valued item
Example
PT:GetBest("Rep.Rewards")
:IsSetMulti(set)
Check to see if a set is a multiset.
Args
- set
- string - name of a set
Returns
boolean - true if set is a multiset, false if set is not, nil if set does not exist.
Remarks
Most handy for determining how to iterate a set table. See :GetSetTable() for more info
Example
PT:IsSetMulti("InstanceLoot.Tempest Keep")
:IterateSet(set)
Iterate all the items in a given set.
Args
- set
- string - name of a set
Returns
number - itemid of the item string or boolean - value of the item string - set origin of the item
Example
for item, value, set in PT:IterateSet("Misc.Minipet") do self:Print(item,value,set) end
Comments