From 73dae43c79253ad49b4bbf24cdb373da81236294 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Sun, 6 Apr 2014 18:45:10 +0000 Subject: [PATCH] Avoid using "select" function unless required. It's simpler and more efficient to make use of setting variables to multiple return values. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1259 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleAura.lua | 15 +++++++-------- OvaleBestAction.lua | 3 +-- OvaleComboPoints.lua | 11 ++++++----- OvaleCooldown.lua | 2 +- OvaleDamageTaken.lua | 21 ++++++++++----------- OvaleEclipse.lua | 3 +-- OvaleEnemies.lua | 6 ++---- OvaleEquipement.lua | 5 ++--- OvaleFuture.lua | 20 +++++++++----------- OvaleLatency.lua | 4 ++-- OvaleOptions.lua | 2 +- OvalePaperDoll.lua | 3 +-- OvalePower.lua | 3 +-- OvaleRunes.lua | 3 +-- OvaleScripts.lua | 2 +- OvaleSpellBook.lua | 10 +++++----- OvaleSpellDamage.lua | 15 +++++++++------ conditions/CastTime.lua | 7 +++---- conditions/PTR.lua | 3 +-- conditions/PowerCost.lua | 4 ++-- conditions/RemainingCastTime.lua | 13 ++++++------- conditions/Threat.lua | 3 +-- conditions/Ticks.lua | 4 ++-- conditions/TimeToPowerFor.lua | 3 +-- conditions/TotemExpires.lua | 1 - 25 files changed, 76 insertions(+), 90 deletions(-) diff --git a/OvaleAura.lua b/OvaleAura.lua index 22fdcb3..b2e07dd 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -33,7 +33,6 @@ local bit_bor = bit.bor local floor = math.floor local ipairs = ipairs local pairs = pairs -local select = select local tinsert = table.insert local tsort = table.sort local wipe = table.wipe @@ -280,20 +279,20 @@ function OvaleAura:OnDisable() self_pool:Drain() end -function OvaleAura:COMBAT_LOG_EVENT_UNFILTERED(event, ...) - local timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1, ...) +function OvaleAura:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cleuEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...) + local arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23 = ... - if CLEU_AURA_EVENTS[event] then + if CLEU_AURA_EVENTS[cleuEvent] then local unitId = OvaleGUID:GetUnitId(destGUID) if unitId and not OvaleGUID.UNIT_AURA_UNIT[unitId] then - Ovale:DebugPrintf(OVALE_AURA_DEBUG, "%s: %s", event, unitId) + Ovale:DebugPrintf(OVALE_AURA_DEBUG, "%s: %s", cleuEvent, unitId) self:ScanAurasOnGUID(destGUID) end - elseif sourceGUID == self_guid and CLEU_TICK_EVENTS[event] then + elseif sourceGUID == self_guid and CLEU_TICK_EVENTS[cleuEvent] then -- Update the latest tick time of the periodic aura cast by the player. - local spellId, spellName, spellSchool = select(12, ...) + local spellId, spellName, spellSchool = arg12, arg13, arg14 local unitId = OvaleGUID:GetUnitId(destGUID) - Ovale:DebugPrintf(OVALE_AURA_DEBUG, "%s: %s", event, unitId) + Ovale:DebugPrintf(OVALE_AURA_DEBUG, "%s: %s", cleuEvent, unitId) local aura = GetAura(self.aura, destGUID, spellId, self_guid) if self:IsActiveAura(aura) then local name = aura.name or "Unknown spell" diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua index 17320f0..040265b 100644 --- a/OvaleBestAction.lua +++ b/OvaleBestAction.lua @@ -33,7 +33,6 @@ local floor = math.floor local ipairs = ipairs local loadstring = loadstring local pairs = pairs -local select = select local strfind = string.find local tonumber = tonumber local tostring = tostring @@ -106,7 +105,7 @@ local function ComputeAction(element) if si and si.casttime then element.castTime = si.casttime else - local castTime = select(7, API_GetSpellInfo(spellId)) + local _, _, _, _, _, _, castTime = API_GetSpellInfo(spellId) if castTime then element.castTime = castTime / 1000 else diff --git a/OvaleComboPoints.lua b/OvaleComboPoints.lua index 28ffc21..496bbd9 100644 --- a/OvaleComboPoints.lua +++ b/OvaleComboPoints.lua @@ -24,7 +24,7 @@ local API_UnitClass = UnitClass local MAX_COMBO_POINTS = MAX_COMBO_POINTS -- Player's class. -local self_class = select(2, API_UnitClass("player")) +local _, self_class = API_UnitClass("player") -- -- @@ -75,11 +75,12 @@ An ability that generates extra combo points after it critically strikes the tar should have a "critcombo=N" parameter in its SpellInfo() description, where N is the number of extra combo points to add, e.g., critcombo=1. --]] -function OvaleComboPoints:COMBAT_LOG_EVENT_UNFILTERED(event, ...) - local _, event, _, sourceGUID, _, _, _, destGUID = ... +function OvaleComboPoints:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cleuEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...) + local arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23 = ... + if sourceGUID == OvaleGUID:GetGUID("player") and destGUID == OvaleGUID:GetGUID("target") then - if event == "SPELL_DAMAGE" then - local spellId, _, _, _, _, _, _, _, _, critical = select(12, ...) + if cleuEvent == "SPELL_DAMAGE" then + local spellId, critical = arg12, arg21 local si = OvaleData.spellInfo[spellId] if critical and si and si.critcombo then self.combo = self.combo + si.critcombo diff --git a/OvaleCooldown.lua b/OvaleCooldown.lua index 3ff9c01..f2254eb 100644 --- a/OvaleCooldown.lua +++ b/OvaleCooldown.lua @@ -26,7 +26,7 @@ local API_UnitHealthMax = UnitHealthMax local API_UnitClass = UnitClass -- Player's class. -local self_class = select(2, API_UnitClass("player")) +local _, self_class = API_UnitClass("player") -- -- diff --git a/OvaleDamageTaken.lua b/OvaleDamageTaken.lua index 10b9886..7854ba9 100644 --- a/OvaleDamageTaken.lua +++ b/OvaleDamageTaken.lua @@ -20,7 +20,6 @@ local OvaleQueue = Ovale.OvaleQueue -- Forward declarations for module dependencies. local OvaleLatency = nil -local select = select local API_GetTime = GetTime local API_UnitGUID = UnitGUID @@ -57,18 +56,18 @@ function OvaleDamageTaken:OnDisable() self_pool:Drain() end -function OvaleDamageTaken:COMBAT_LOG_EVENT_UNFILTERED(event, ...) - local timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1, ...) - if destGUID == self_guid and event:find("_DAMAGE") then +function OvaleDamageTaken:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cleuEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...) + local arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23 = ... + + if destGUID == self_guid and cleuEvent:find("_DAMAGE") then local now = API_GetTime() - if event:find("SWING_") == 1 then - local amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = select(12, ...) - Ovale:DebugPrintf(OVALE_DAMAGE_TAKEN_DEBUG, "%s caused %d damage.", event, amount) + if cleuEvent:find("SWING_") == 1 then + local amount = arg12 + Ovale:DebugPrintf(OVALE_DAMAGE_TAKEN_DEBUG, "%s caused %d damage.", cleuEvent, amount) self:AddDamageTaken(now, amount) - elseif event:find("RANGE_") == 1 or event:find("SPELL_") == 1 then - local spellId, spellName, spellSchool = select(12, ...) - local amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = select(15, ...) - Ovale:DebugPrintf(OVALE_DAMAGE_TAKEN_DEBUG, "%s (%s) caused %d damage.", event, spellName, amount) + elseif cleuEvent:find("RANGE_") == 1 or cleuEvent:find("SPELL_") == 1 then + local spellName, amount = arg13, arg15 + Ovale:DebugPrintf(OVALE_DAMAGE_TAKEN_DEBUG, "%s (%s) caused %d damage.", cleuEvent, spellName, amount) self:AddDamageTaken(now, amount) end end diff --git a/OvaleEclipse.lua b/OvaleEclipse.lua index b9d3065..b54fa27 100644 --- a/OvaleEclipse.lua +++ b/OvaleEclipse.lua @@ -21,7 +21,6 @@ local OvaleData = nil local OvaleSpellBook = nil local OvaleState = nil -local select = select local API_GetEclipseDirection = GetEclipseDirection local API_UnitClass = UnitClass local API_UnitGUID = UnitGUID @@ -33,7 +32,7 @@ local OVALE_ECLIPSE_DEBUG = "eclipse" -- Player's GUID. local self_guid = nil -- Player's class. -local self_class = select(2, API_UnitClass("player")) +local _, self_class = API_UnitClass("player") local LUNAR_ECLIPSE = ECLIPSE_BAR_LUNAR_BUFF_ID local SOLAR_ECLIPSE = ECLIPSE_BAR_SOLAR_BUFF_ID diff --git a/OvaleEnemies.lua b/OvaleEnemies.lua index a18695d..9b45aff 100644 --- a/OvaleEnemies.lua +++ b/OvaleEnemies.lua @@ -17,7 +17,6 @@ Ovale.OvaleEnemies = OvaleEnemies -- local bit_band = bit.band local pairs = pairs -local select = select local tostring = tostring local wipe = table.wipe local API_GetTime = GetTime @@ -59,10 +58,9 @@ function OvaleEnemies:OnDisable() self:UnregisterEvent("PLAYER_REGEN_DISABLED") end -function OvaleEnemies:COMBAT_LOG_EVENT_UNFILTERED(event, ...) - local timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1, ...) +function OvaleEnemies:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cleuEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...) local now = API_GetTime() - if event == "UNIT_DIED" then + if cleuEvent == "UNIT_DIED" then self:RemoveEnemy(destGUID, true) elseif sourceFlags and bit_band(sourceFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) > 0 and bit_band(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) > 0 diff --git a/OvaleEquipement.lua b/OvaleEquipement.lua index f6f8dcb..1f790a4 100644 --- a/OvaleEquipement.lua +++ b/OvaleEquipement.lua @@ -14,7 +14,6 @@ Ovale.OvaleEquipement = OvaleEquipement -- local pairs = pairs -local select = select local strgsub = string.gsub local strmatch = string.match local tonumber = tonumber @@ -1295,7 +1294,7 @@ OvaleEquipement.offHandWeaponSpeed = nil local function GetEquippedItemType(slotId) local itemId = OvaleEquipement:GetEquippedItem(slotId) if itemId then - local inventoryType = select(9, API_GetItemInfo(itemId)) + local _, _, _, _, _, _, _, _, inventoryType = API_GetItemInfo(itemId) return inventoryType end end @@ -1318,7 +1317,7 @@ local function GetNormalizedWeaponSpeed(slotId) if slotId == INVSLOT_MAINHAND or slotId == INVSLOT_OFFHAND then local itemId = OvaleEquipement:GetEquippedItem(slotId) if itemId then - local weaponClass = select(7, API_GetItemInfo(itemId)) + local _, _, _, _, _, _, weaponClass = API_GetItemInfo(itemId) return OVALE_NORMALIZED_WEAPON_SPEED[weaponClass] end end diff --git a/OvaleFuture.lua b/OvaleFuture.lua index 0a3eb58..3629db6 100644 --- a/OvaleFuture.lua +++ b/OvaleFuture.lua @@ -30,7 +30,6 @@ local OvaleState = nil local ipairs = ipairs local pairs = pairs -local select = select local tinsert = table.insert local tostring = tostring local tremove = table.remove @@ -347,7 +346,7 @@ end function OvaleFuture:UNIT_SPELLCAST_CHANNEL_START(event, unit, name, rank, lineId, spellId) if unit == "player" then - local startTime, endTime = select(5, API_UnitChannelInfo("player")) + local _, _, _, _, startTime, endTime = API_UnitChannelInfo("player") TracePrintf(spellId, "%s: %d, lineId=%d, startTime=%f, endTime=%f", event, spellId, lineId, startTime, endTime) AddSpellToQueue(spellId, lineId, startTime/1000, endTime/1000, true, false) @@ -364,7 +363,7 @@ end --Called when a spell started its cast function OvaleFuture:UNIT_SPELLCAST_START(event, unit, name, rank, lineId, spellId) if unit == "player" then - local startTime, endTime = select(5, API_UnitCastingInfo("player")) + local _, _, _, _, startTime, endTime = API_UnitCastingInfo("player") TracePrintf(spellId, "%s: %d, lineId=%d, startTime=%f, endTime=%f", event, spellId, lineId, startTime, endTime) AddSpellToQueue(spellId, lineId, startTime/1000, endTime/1000, false, false) @@ -443,8 +442,8 @@ function OvaleFuture:UNIT_SPELLCAST_SUCCEEDED(event, unit, name, rank, lineId, s end end -function OvaleFuture:COMBAT_LOG_EVENT_UNFILTERED(event, ...) - local timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1, ...) +function OvaleFuture:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cleuEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...) + local arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23 = ... --[[ Sequence of events: @@ -487,12 +486,12 @@ function OvaleFuture:COMBAT_LOG_EVENT_UNFILTERED(event, ...) -- Called when a missile reaches or misses its target if sourceGUID == self_guid then - if OVALE_CLEU_SPELLCAST_RESULTS[event] then - local spellId, spellName = select(12, ...) - TracePrintf(spellId, "%s: %s (%d)", event, spellName, spellId) + if OVALE_CLEU_SPELLCAST_RESULTS[cleuEvent] then + local spellId, spellName = arg12, arg13 + TracePrintf(spellId, "%s: %s (%d)", cleuEvent, spellName, spellId) for index, spellcast in ipairs(self_activeSpellcast) do if spellcast.allowRemove and (spellcast.spellId == spellId or spellcast.auraId == spellId) then - if not spellcast.channeled and (spellcast.removeOnSuccess or event ~= "SPELL_CAST_SUCCESS") then + if not spellcast.channeled and (spellcast.removeOnSuccess or cleuEvent ~= "SPELL_CAST_SUCCESS") then TracePrintf(spellId, " Spell finished: %s (%d)", spellName, spellId) tremove(self_activeSpellcast, index) UpdateLastSpellcast(spellcast) @@ -699,8 +698,7 @@ statePrototype.ApplySpell = function(state, ...) -- Handle missing start/end/next cast times. if not startCast or not endCast or not nextCast then - local castTime = 0 - local castTime = select(7, API_GetSpellInfo(spellId)) + local _, _, _, _, _, _, castTime = API_GetSpellInfo(spellId) castTime = castTime and (castTime / 1000) or 0 local gcd = OvaleCooldown:GetGCD(spellId) diff --git a/OvaleLatency.lua b/OvaleLatency.lua index f69936e..c4c6132 100644 --- a/OvaleLatency.lua +++ b/OvaleLatency.lua @@ -12,7 +12,6 @@ local OvaleLatency = Ovale:NewModule("OvaleLatency", "AceEvent-3.0") Ovale.OvaleLatency = OvaleLatency -- -local select = select local API_GetNetStats = GetNetStats local API_GetTime = GetTime -- @@ -74,7 +73,8 @@ function OvaleLatency:GetLatency() -- using GetNetStats(). local now = API_GetTime() if not self.latency or not self.lastUpdateTime or now - self.lastUpdateTime > 10 then - self.latency = select(4, API_GetNetStats()) / 1000 + local _, _, _, latency = API_GetNetStats() + self.latency = latency / 1000 end return self.latency end diff --git a/OvaleOptions.lua b/OvaleOptions.lua index 2331d96..0f9e153 100644 --- a/OvaleOptions.lua +++ b/OvaleOptions.lua @@ -29,7 +29,7 @@ local API_GetSpellInfo = GetSpellInfo local API_UnitClass = UnitClass -- Player's class. -local self_class = select(2, API_UnitClass("player")) +local _, self_class = API_UnitClass("player") -- -- diff --git a/OvalePaperDoll.lua b/OvalePaperDoll.lua index d8f554c..fb6d6f4 100644 --- a/OvalePaperDoll.lua +++ b/OvalePaperDoll.lua @@ -21,7 +21,6 @@ local OvaleEquipement = nil local OvaleStance = nil local OvaleState = nil -local select = select local tonumber = tonumber local API_GetCritChance = GetCritChance local API_GetMasteryEffect = GetMasteryEffect @@ -43,7 +42,7 @@ local API_UnitSpellHaste = UnitSpellHaste local API_UnitStat = UnitStat -- Player's class. -local self_class = select(2, API_UnitClass("player")) +local _, self_class = API_UnitClass("player") -- Snapshot table pool. local self_pool = OvalePoolRefCount("OvalePaperDoll_pool") -- Total number of snapshots taken. diff --git a/OvalePower.lua b/OvalePower.lua index 0810177..bd7d287 100644 --- a/OvalePower.lua +++ b/OvalePower.lua @@ -18,7 +18,6 @@ local OvaleData = nil local OvaleState = nil local pairs = pairs -local select = select local API_GetPowerRegen = GetPowerRegen local API_GetSpellInfo = GetSpellInfo local API_UnitPower = UnitPower @@ -283,7 +282,7 @@ function OvalePower:ApplySpellAfterCast(state, spellId, targetGUID, startCast, e -- Update power using information from GetSpellInfo() if there is no SpellInfo() for the spell's cost. do - local cost, _, powerType = select(4, API_GetSpellInfo(spellId)) + local _, _, _, cost, _, powerType = API_GetSpellInfo(spellId) if cost and powerType then powerType = self.POWER_TYPE[powerType] if not si or not si[powerType] then diff --git a/OvaleRunes.lua b/OvaleRunes.lua index f427aa8..d1f0c0e 100644 --- a/OvaleRunes.lua +++ b/OvaleRunes.lua @@ -26,14 +26,13 @@ local OvaleState = nil local ipairs = ipairs local pairs = pairs -local select = select local API_GetRuneCooldown = GetRuneCooldown local API_GetRuneType = GetRuneType local API_GetTime = GetTime local API_UnitClass = UnitClass -- Player's class. -local self_class = select(2, API_UnitClass("player")) +local _, self_class = API_UnitClass("player") local BLOOD_RUNE = 1 local UNHOLY_RUNE = 2 diff --git a/OvaleScripts.lua b/OvaleScripts.lua index 3ad634f..66aa8f8 100644 --- a/OvaleScripts.lua +++ b/OvaleScripts.lua @@ -18,7 +18,7 @@ local pairs = pairs local API_UnitClass = UnitClass -- Player's class. -local self_class = select(2, API_UnitClass("player")) +local _, self_class = API_UnitClass("player") -- -- diff --git a/OvaleSpellBook.lua b/OvaleSpellBook.lua index 1f5effb..43d4f4d 100644 --- a/OvaleSpellBook.lua +++ b/OvaleSpellBook.lua @@ -17,7 +17,7 @@ Ovale.OvaleSpellBook = OvaleSpellBook -- local ipairs = ipairs local pairs = pairs -local strfind = string.find +local strmatch = string.match local tinsert = table.insert local tonumber = tonumber local tostring = tostring @@ -49,9 +49,9 @@ OvaleSpellBook.glyph = {} -- -- --- Return the four components of a hyperlink: color, linktype, linkdata, text. local function ParseHyperlink(hyperlink) - return select(3, strfind(hyperlink, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+)|?h?%[?([^%[%]]*)%]?|?h?|?r?")) + local color, linkType, linkData, text = strmatch(hyperlink, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+)|?h?%[?([^%[%]]*)%]?|?h?|?r?") + return color, linkType, linkData, text end local function PrintTableValues(tbl) @@ -175,8 +175,8 @@ function OvaleSpellBook:ScanSpellBook(bookType, numSpells, offset) -- i.e., through talents or Symbiosis. local spellLink = API_GetSpellLink(index, bookType) if spellLink then - local linkdata, spellName = select(3, ParseHyperlink(spellLink)) - self.spell[tonumber(linkdata)] = spellName + local _, _, linkData, spellName = ParseHyperlink(spellLink) + self.spell[tonumber(linkData)] = spellName if spellId then self.spell[spellId] = spellName end diff --git a/OvaleSpellDamage.lua b/OvaleSpellDamage.lua index 3322416..963fdc9 100644 --- a/OvaleSpellDamage.lua +++ b/OvaleSpellDamage.lua @@ -15,10 +15,13 @@ local OvaleSpellDamage = Ovale:NewModule("OvaleSpellDamage", "AceEvent-3.0") Ovale.OvaleSpellDamage = OvaleSpellDamage -- -local select = select -local strfind = string.find local API_UnitGUID = UnitGUID +local CLEU_DAMAGE_EVENT = { + SPELL_DAMAGE = true, + SPELL_PERIODIC_AURA = true, +} + -- Player's GUID. local self_guid = nil -- @@ -37,12 +40,12 @@ function OvaleSpellDamage:OnDisable() self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED") end -function OvaleSpellDamage:COMBAT_LOG_EVENT_UNFILTERED(event, ...) - local time, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1, ...) +function OvaleSpellDamage:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cleuEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...) + local arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23 = ... if sourceGUID == self_guid then - if strfind(event, "SPELL_PERIODIC_DAMAGE")==1 or strfind(event, "SPELL_DAMAGE")==1 then - local spellId, spellName, spellSchool, amount = select(12, ...) + if CLEU_DAMAGE_EVENT[cleuEvent] then + local spellId, amount = arg12, arg15 self.value[spellId] = amount end end diff --git a/conditions/CastTime.lua b/conditions/CastTime.lua index 36a0a50..51bb939 100644 --- a/conditions/CastTime.lua +++ b/conditions/CastTime.lua @@ -13,7 +13,6 @@ local _, Ovale = ... do local OvaleCondition = Ovale.OvaleCondition - local select = select local API_GetSpellInfo = GetSpellInfo local Compare = OvaleCondition.Compare @@ -37,9 +36,9 @@ do local spellId, comparator, limit = condition[1], condition[2], condition[3] local castTime = 0 if spellId then - castTime = select(7, API_GetSpellInfo(spellId)) - if castTime then - castTime = castTime / 1000 + local _, _, _, _, _, _, _castTime = API_GetSpellInfo(spellId) + if _castTime then + castTime = _castTime / 1000 Ovale:Logf("castTime = %f %s %s", castTime, comparator, limit) end end diff --git a/conditions/PTR.lua b/conditions/PTR.lua index 19c7bad..bb29c99 100644 --- a/conditions/PTR.lua +++ b/conditions/PTR.lua @@ -13,7 +13,6 @@ local _, Ovale = ... do local OvaleCondition = Ovale.OvaleCondition - local select = select local API_GetBuildInfo = GetBuildInfo local TestBoolean = OvaleCondition.TestBoolean @@ -26,7 +25,7 @@ do local function PTR(condition) local yesno = condition[1] - local uiVersion = select(4, API_GetBuildInfo()) + local _, _, _, uiVersion = API_GetBuildInfo() local boolean = (uiVersion > 50400) return TestBoolean(boolean, yesno) end diff --git a/conditions/PowerCost.lua b/conditions/PowerCost.lua index 53b1e05..a9b710d 100644 --- a/conditions/PowerCost.lua +++ b/conditions/PowerCost.lua @@ -12,7 +12,6 @@ local _, Ovale = ... do local OvaleCondition = Ovale.OvaleCondition - local select = select local API_GetSpellInfo = GetSpellInfo local Compare = OvaleCondition.Compare @@ -31,7 +30,8 @@ do local function PowerCost(condition) local spellId, comparator, limit = condition[1], condition[2], condition[3] - local value = select(4, API_GetSpellInfo(spellId)) or 0 + local _, _, _, cost = API_GetSpellInfo(spellId) + local value = cost or 0 return Compare(value, comparator, limit) end diff --git a/conditions/RemainingCastTime.lua b/conditions/RemainingCastTime.lua index 0c39e85..282cefb 100644 --- a/conditions/RemainingCastTime.lua +++ b/conditions/RemainingCastTime.lua @@ -13,7 +13,6 @@ local _, Ovale = ... do local OvaleCondition = Ovale.OvaleCondition - local select = select local API_UnitCastingInfo = UnitCastingInfo local ParseCondition = OvaleCondition.ParseCondition local TestValue = OvaleCondition.TestValue @@ -36,13 +35,13 @@ do local function RemainingCastTime(condition) local comparator, limit = condition[1], condition[2] local target = ParseCondition(condition) - local startTime, endTime = select(5, API_UnitCastingInfo(target)) - if not startTime or not endTime then - return nil + local _, _, _, _, startTime, endTime = API_UnitCastingInfo(target) + if startTime and endTime then + startTime = startTime / 1000 + endTime = endTime / 1000 + return TestValue(startTime, endTime, 0, endTime, -1, comparator, limit) end - startTime = startTime / 1000 - endTime = endTime / 1000 - return TestValue(startTime, endTime, 0, endTime, -1, comparator, limit) + return nil end OvaleCondition:RegisterCondition("remainingcasttime", false, RemainingCastTime) diff --git a/conditions/Threat.lua b/conditions/Threat.lua index 75bfccf..6175285 100644 --- a/conditions/Threat.lua +++ b/conditions/Threat.lua @@ -13,7 +13,6 @@ local _, Ovale = ... do local OvaleCondition = Ovale.OvaleCondition - local select = select local API_UnitDetailedThreatSituation = UnitDetailedThreatSituation local Compare = OvaleCondition.Compare local ParseCondition = OvaleCondition.ParseCondition @@ -36,7 +35,7 @@ do local function Threat(condition) local comparator, limit = condition[1], condition[2] local target = ParseCondition(condition, "target") - local value = select(3, API_UnitDetailedThreatSituation("player", target)) + local _, _, value = API_UnitDetailedThreatSituation("player", target) return Compare(value, comparator, limit) end diff --git a/conditions/Ticks.lua b/conditions/Ticks.lua index e28ef47..be62992 100644 --- a/conditions/Ticks.lua +++ b/conditions/Ticks.lua @@ -15,7 +15,6 @@ do local OvaleState = Ovale.OvaleState local floor = math.floor - local select = select local Compare = OvaleCondition.Compare local ParseCondition = OvaleCondition.ParseCondition local state = OvaleState.state @@ -41,7 +40,8 @@ do numTicks = floor((ending - start) / tick + 0.5) end else - numTicks = select(3, state:GetDuration(auraId)) + local _, _, _numTicks = state:GetDuration(auraId) + numTicks = _numTicks end if numTicks then return Compare(numTicks, comparator, limit) diff --git a/conditions/TimeToPowerFor.lua b/conditions/TimeToPowerFor.lua index 77ae867..eba90b0 100644 --- a/conditions/TimeToPowerFor.lua +++ b/conditions/TimeToPowerFor.lua @@ -14,7 +14,6 @@ do local OvalePower = Ovale.OvalePower local OvaleState = Ovale.OvaleState - local select = select local API_GetSpellInfo = GetSpellInfo local Compare = OvaleCondition.Compare local TestValue = OvaleCondition.TestValue @@ -32,7 +31,7 @@ do local function TimeToPowerFor(condition) local spellId, comparator, limit = condition[1], condition[2], condition[3] - local cost, _, powerToken = select(4, API_GetSpellInfo(spellId)) + local _, _, _, cost, _, powerToken = API_GetSpellInfo(spellId) local powerType = OvalePower.POWER_TYPE[powerToken] local currentPower = state[powerType] local powerRate = state.powerRate[powerType] diff --git a/conditions/TotemExpires.lua b/conditions/TotemExpires.lua index c73e184..306fa39 100644 --- a/conditions/TotemExpires.lua +++ b/conditions/TotemExpires.lua @@ -14,7 +14,6 @@ do local OvaleCondition = Ovale.OvaleCondition local OvaleSpellBook = Ovale.OvaleSpellBook - local select = select local type = type local API_GetTotemInfo = GetTotemInfo -- 1.7.9.5