-
-
Notifications
You must be signed in to change notification settings - Fork 75
Useful Variables
In GSE Variables are placeholders for dynamic information constructed using the WoW API (functions).
These functions are constructed of pure Lua. They are evaluated out of combat everytime you zone, change target, change talents etc. Each function must return a value and the resulting value is what is placed into the template. Below is the minimum of what is needed for a function variable.
function()
return something
end
Function variables use the WoW API for things like "am I of this race" or "in this covenant". As they are programming code, they can return any Lua datatype, but the most common use is to return a string. The exception to this is Binary functions. To use an IF block, a function variable has to be present, returning a binary true
or false
value.
Note: Variables are not able to be checked in combat. WoW has a couple of anti-botting provisions. A mod can either cast a preset list of spells and abilities (like GSE) but when it looks at combo points or mana or target health or any of those extremely useful things to know in combat, it is then reduced to only being able to draw pretty pictures on the screen (like WeakAuras) and can no longer cast spells.
function()
if UnitRace("player") == "Orc" then
return true
else
return false
end
end
A Binary Function will only return true or false
A list of functions for the WoW API can be found at https://warcraft.wiki.gg/wiki/World_of_Warcraft_API
Each variable is loaded into a special namespace - GSE.V
. Each Variable can then be referenced as GSE.V.VariableName()
or GSE.V["VariableName"]()
. This allows these variables to be used in other mods like Weakauras. When calculating the number of characters in a macrotext action, GSE will count the result from the Variable.
To use a variable in GSE use the following =GSE.V.VariableName()
on either a blank line in Macrotext or as the only entry in a Spell or Unit Box. This has to be on its own line and the =
must be the first character on that line. You can also use varagrs if your function supports it eg =GSE.V.TopDPS(2)
Pass in that we want the second value from the TopDPS variable.
This example will insert the value of the Afflicted variable from below this page into the macrotext on a GSE Sequence Action.
=GSE.V.Afflicted()
/targetenemy [noharm][dead]
/cast spell1
To obtain from Details the Highest DPS from the last fight:
function(slot)
if GSE.isEmpty(slot) then
slot = 1
end
local function GetDetailsDamage()
local combat = Details:GetCurrentCombat()
local damageContainer = combat:GetContainer (DETAILS_ATTRIBUTE_DAMAGE)
local actorsAmount = GSE.NewTable()
for i, actor in damageContainer:ListActors() do
local amount = actor.total
if (amount and amount >= 1) then
local tempTable = GSE.NewTable()
tempTable["name"] = actor:name()
tempTable["total"] = amount
tinsert(actorsAmount, tempTable)
end
end
table.sort (actorsAmount, function(a,b) return a.total > b.total end)
return actorsAmount
end
if GetNumGroupMembers() < 1 then
return "player"
end
local detailsUnitName = GetDetailsDamage()[slot].name
local unitName = detailsUnitName
local prefix = IsInRaid() and "raid" or "party"
for k=1, GetNumGroupMembers() do
local unit = prefix..tostring(k)
local unitFullName = UnitName(unit)
if not GSE.isEmpty(unitFullName) then
if string.sub(unitName, 1, string.len(unitFullName)) == unitFullName then
return unit
end
end
end
return "player"
end
Find first Tank in group/raid
function()
if GetNumGroupMembers() < 1 then
return "player"
end
local prefix = IsInRaid() and "raid" or "party"
for k=1, GetNumGroupMembers() do
local unit = prefix..tostring(k)
if UnitGroupRolesAssigned(unit) == "TANK" then
return unit
end
end
end
Check if a Spell is known. This takes either an ID or a Spell Name
function(spellID)
if not spellID then
return false
end
local SpellBookSlot = C_SpellBook.FindSpellBookSlotForSpell(spellID)
if SpellBookSlot then
return SpellBookSlot > 0
else
return false
end
end
Add a dispell as a mouseover when doing keys with the Afflicted affix.
function()
local cleanse = {
[2] = "Cleanse Toxins", -- Paladin also Cleanse
[5] = "Improved Purify", -- Priest also Power Word: Life
[7] = "Purify Spirit", -- Shaman also Poison Cleansing Totem
[8] = "Remove Curse", -- Mage
[10] = "Detox", -- Monk
[11] = "Nature's Cure", -- Druid also Remove Corruption
[13] = "Naturalize" -- Evoker also Cauterizing Flame and Expunge (for Devastation)
}
if GSE.isEmpty(cleanse[GSE.GetCurrentClassID()]) then
return ""
end
if GSE.inMythicPlus then
local affixlist = C_MythicPlus.GetCurrentAffixes()
for _,j in ipairs(affixlist) do
-- The 135 here is the AffixID for Afflicted. From C_MythicPlus.GetCurrentAffixes()
if j.id == 135 then
-- Change the Cleanse Toxins here to your classes Dispel/Decurse/etc
return "/cast [@mouseover,help,exists] " .. cleanse[GSE.GetCurrentClassID()]
end
end
end
return ""
end
Note: this last variable works can be used in TWW in a Managed Macro.
Use the neck from Battle for Azeroth
function()
local itemLink = GetInventoryItemLink("player", 2)
if not GSE.isEmpty(itemLink) then
local GetItemInfo = C_Item and C_Item.GetItemInfo or GetItemInfo
if GetItemInfo(itemLink) == "Heart of Azeroth" then
return "/cast [combat,nochanneling] Heart Essence"
else
return ""
end
else
return ""
end
end