Skip to content

Useful Variables

Timothy Minahan edited this page Mar 16, 2024 · 4 revisions

Variables in GSE

In GSE Variables are placeholders for either some preset text (Strings) or dynamic information constructed using the WoW API (functions).

String Variables

These return a simple piece of text. That text is simply substituted. eg:

/targetenemy [noharm][dead]

Function Variables

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 "/cast stuff"
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.

function() 
  if UnitRace("player") == "Orc" then 
    return true 
  else 
    return false 
  end 
end

A list of functions for the WoW API can be found at https://warcraft.wiki.gg/wiki/World_of_Warcraft_API

Useful Variables

Highest DPS

To obtain from Details the Highest DPS from the last fight:

function()
 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
 
 -- Change the 2 in this next line to a 3 for Second Highest DPS
 local detailsUnitName = GetDetailsDamage()[2].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

Tank

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

Afflicted

Add a dispell as a mouseover when doing keys with the Afflicted affix.

function()
  If not GSE.isEmpty(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 Toxins"  
      end
    end
  end
  return " "
end