API
r1
Making Changes to PT3
- Changes to the file PeriodicTable-3.0.lua can be made as normal.
- Edit data in data.lua only, then run compresssplit.lua in the command line.
- All new data sets must be added to both data.lua and the corresponding mini-embed (use Misc if it's a smallish data group that doesn't make sense in any of the other files.
- Changes to existing sets must be made ONLY to data.lua, changes made in other places will be overwritten. To make the changes take effect in the other files, run compresssplit.lua in the command line. In addition, be aware that if a set is automatically generated, your changes will be overwritten the next time the dataminer is run -- in those cases, you'll need to make changes directly to dataminer.lua.
Set Types
Basic Set
A set containing itemId or spellId. Optionally, it can have values for those which must be integers and are separated by a colon.
Examples
["Reagent.Ammo.Arrow"] = "31737:500,12654:200,30611:385", ["GearSet.Tier 2.Priest.Vestments of Transcendence"] = "16925,16926,16919,16921,16920,16922,16924,16923", ["ClassSpell.Druid.Restoration"] = "-48435:0,-48436:0,-48437:0,-5185:1,-1126:1,-774:4,..."
Multi Set
A set containing references to sets. These can be used to form links between different points in the data hierarchy.
Examples
["InstanceLoot.Blackrock Spire"] = "m,InstanceLoot.Lower Blackrock Spire,InstanceLoot.Upper Blackrock Spire", ["Tradeskill.Mat.BySource.Gather"] = "m,Tradeskill.Gather",
Remarks
There's no need to define a set that's implied by the hierarchy, PT3 creates these on the fly.
Compressed Set
A set containing multiple sets.
Examples
["Consumable.Bandage.Battleground"] = "c[Alterac Valley,19307:2000][Arathi Basin,20232:1104,20234:2000][Warsong Gulch,19067:1104,19066:2000]",
Remarks
If you request a child of one of these sets, such as (with the above example as the only set) PT:ItemInSet(19066, "Consumable.Bandage.Battleground.Warsong Gulch"), PT3 will automatically discover this and return the correct data.
Any type of set can be stored within these sets, they can also be nested within each other, such as:
"c[Monkey,c[Stuff,c[Tiny,1211:55][Reference,m,InstanceLoot.Blackrock Spire]]]"
In addition, the contained sets must follow all the rules of their set type (specifically, data compression)
Oddball Sets
A set with non-integer values. These values can contain any string data aside from commas.
Examples
["Manufac.Alchemy"] = "o,16797:Elixir,16787:Healing,1235:Some'thing With_Spaces!,12534:111:111:111-2",
Remarks
The itemids must be compressed, the values must be uncompressed.
Uncompressed Sets
A set that does not get uncompressed. In addition, the values can contain any string data aside from commas.
Examples
["MyAddon.Custom"] = "u,7132:Value!!,23684,32116:11",
Remarks
Nothing here gets uncompressed. Use this set type for custom sets that are created on the fly in-game.
Notes on Sets
- Be aware of what you're overwriting.
For example, if you define a set:
["a.b.c"] = "32257:1000,14431:400",
then the sets "a" and "a.b" are assumed from the hierarchy context. If you overwrite one of them, for example:
["a.b"] = "1221:112",
then the flow of the hierarchy is disrupted, as "a.b" should naturally be a multiset that contains it's children. This will not break anything, but be aware of the effects.
A more damaging scenario would be this:
["a.b.c"] = "c[d,1111:11]", ["a.b.c.d"] = "2222:22",
In this case, data will be destroyed - and the kicker is that which data gets destroyed depends on the order in which they're requested.
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
Facts
- Date created
- 28 Oct 2008