- Added slash command '/details api'.

- Major update on our .txt about the API, these files are on the root folder of details! at WoW/Interface/AddOns/Details.
This commit is contained in:
Tercio
2015-10-04 13:46:29 -03:00
parent 0104adf583
commit 9f5d387938
14 changed files with 1265 additions and 95 deletions
+57 -18
View File
@@ -1,25 +1,25 @@
A custom display is made with 4 scripts:
Cstom Display is a special display where users can set their own rules on searching for what show in the window.
There is 4 scripts which compose the display:
Required:
Search - this is the main script, it's responsible to build a list of players to be show in the window.
Search - this is the main script, it's responsible to build a list of actors to show in the window.
Optional:
Tooltip - it run when the user hover over a bar.
Tooltip - it runs when the user hover over a bar.
Total - runs when showing the bar, and helps format the total done.
Percent - also runs when showing the bar, it formats the percentage amount.
Search Code:
- The script receives 3 parameters: *Combat, *Container and *Instance.
- The script receives 3 parameters: *Combat, *CustomContainer and *Instance.
*Combat - is the reference for the selected combat shown in the window (the one selected on segments menu).
*Container - is the place where the display mantain stored the results, Details! get the content inside the container and use to update the window.
*Instance - is the reference of the window where the custom display is being shown.
*CustomContainer - is the place where the display mantain stored the results, Details! get the content inside the container and use to update the window.
*Instance - is the reference of the window where the custom display is shown.
- Also, the script must return three values: total made by all players, the amount of the top player and the amount of players found by the script.
- The search script basicaly begins getting these three parameters and declaring our three return values:
- The search script basically begins getting these three parameters and declaring our three return values:
local combat, instance_container, instance = ...
local Combat, CustomContainer, Instance = ...
local total, top, amount = 0, 0, 0
- Then, we build our search for wherever we want to show, here we are building an example for Damage Done by Pets and Guardians.
@@ -43,20 +43,20 @@ if (petOwner:IsPlayer()) then
local petDamage = actor.total
end
- The next step is add the pet owner into the Container:
- The next step is add the pet owner into the CustomContainer:
Container:AddValue (petOwner, petDamage)
CustomContainer:AddValue (petOwner, petDamage)
- And in the and, we need to get the total, top and amount values. This is generally calculated inside our loop above, but just calling the API for the result is more handy:
total, top = Container:GetTotalAndHighestValue()
amount = Container:GetNumActors()
total, top = CustomContainer:GetTotalAndHighestValue()
amount = CustomContainer:GetNumActors()
return total, top, amount
The finished script looks like this:
local Combat, Container, Instance = ...
local Combat, CustomContainer, Instance = ...
local total, top, amount = 0, 0, 0
local damage_container = Combat:GetActorList( DETAILS_ATTRIBUTE_DAMAGE )
@@ -65,13 +65,13 @@ for i, actor in ipairs( damage_container ) do
local petOwner = actor.owner
if (petOwner:IsPlayer()) then
local petDamage = actor.total
Container:AddValue( petOwner, petDamage )
CustomContainer:AddValue( petOwner, petDamage )
end
end
end
total, top = Container:GetTotalAndHighestValue()
amount = Container:GetNumActors()
total, top = CustomContainer:GetTotalAndHighestValue()
amount = CustomContainer:GetNumActors()
return total, top, amount
@@ -131,4 +131,43 @@ Total Code and Percent Code:
local value, top, total, combat, instance = ...
local result = floor (value)
return total
return total
Custom Container Object:
=======================================
A custom container is primarily used when building custom displays.
Is used to hold values for any kind of actor in Details! and also any other table as long as it has a ".name" or ".id" key.
value = is a number indicating the actor's score, the container doesn't know what kind of actor it is holding, if is a damage actor, energy, a spell, so, it is just nominated 'value'.
container:GetValue ( actor )
returns the current value for the requested actor.
container:AddValue ( actor, amountToAdd, checkTop, nameComplement )
actor is any actor object or any other table containing a member "name" or "id", e.g. {name = "Jeff"} {id = 186451}
amountToAdd is the amount to add to this actor on the container.
checkTop is for some special cases when the top value needs to be calculated immediately.
nameComplement is a string to add on the end of the actor's name, for instance, in cases where the actor is a spell and its name is generated by the container.
returns the current value for the actor.
container:SetValue (actor, amount, nameComplement)
actor is any actor object or any other table containing a member "name" or "id", e.g. {name = "Jeff"} {id = 186451}
amount is the amount to set to this actor on the container.
nameComplement is a string to add on the end of the actor's name, for instance, in cases where the actor is a spell and its name is generated by the container.
container:HasActor (actor)
return true if the container holds a reference for 'actor'.
container:GetNumActors()
returns the amount of actors present inside the container.
container:GetTotalAndHighestValue()
return 'total' and 'top' values.
total is the total of value of all actors together.
top is the amount of value of the actor with more value.
container:WipeCustomActorContainer()
removes all data from a custom container.
this is automatically performed when the search script runs.