From 24096f0aec6524889998778a2ed3c07d1ab58c54 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Fri, 12 Oct 2012 00:46:16 +0000 Subject: [PATCH] Use standard library function "tostring" instead of nilstring. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@589 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleBestAction.lua | 34 +++++++++++++++------------------- OvaleCondition.lua | 16 +++++----------- OvaleState.lua | 13 ++----------- 3 files changed, 22 insertions(+), 41 deletions(-) diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua index 4c0a018..a10b785 100644 --- a/OvaleBestAction.lua +++ b/OvaleBestAction.lua @@ -9,15 +9,11 @@ OvaleBestAction = {} --- -local function nilstring(text) - if text == nil then - return "nil" - else - return text - end -end +-- +local tostring = tostring +-- +-- local function printTime(temps) if (temps == nil) then Ovale:Print("> nil") @@ -153,7 +149,7 @@ function OvaleBestAction:GetActionInfo(element) end if (Ovale.trace) then - Ovale:Print("Item "..nilstring(itemId)) + Ovale:Print("Item "..tostring(itemId)) end local spellName = GetItemSpell(itemId) @@ -254,7 +250,7 @@ function OvaleBestAction:Compute(element) else restant = actionCooldownDuration + actionCooldownStart end - Ovale:Log("restant = "..restant.." attenteFinCast="..nilstring(OvaleState.attenteFinCast)) + Ovale:Log("restant = "..restant.." attenteFinCast="..tostring(OvaleState.attenteFinCast)) if restanttimeB) then if Ovale.trace then Ovale:Print(element.type.." return 0") end return 0 @@ -425,7 +421,7 @@ function OvaleBestAction:Compute(element) endB = endA end if Ovale.trace then - Ovale:Print(element.type.." return "..nilstring(startB)..","..nilstring(endB).." ["..element.nodeId.."]") + Ovale:Print(element.type.." return "..tostring(startB)..","..tostring(endB).." ["..element.nodeId.."]") end return startB, endB, prioriteB, elementB elseif element.type == "unless" then @@ -441,7 +437,7 @@ function OvaleBestAction:Compute(element) end if isAfterEqual(startA, startB) and isBefore(endA, endB) then - if Ovale.trace then Ovale:Print(element.type.." return "..nilstring(endA)..","..nilstring(endB)) end + if Ovale.trace then Ovale:Print(element.type.." return "..tostring(endA)..","..tostring(endB)) end return endA, endB, prioriteB, elementB end @@ -453,7 +449,7 @@ function OvaleBestAction:Compute(element) startB = endA end - if Ovale.trace then Ovale:Print(element.type.." return "..nilstring(startB)..","..nilstring(endB)) end + if Ovale.trace then Ovale:Print(element.type.." return "..tostring(startB)..","..tostring(endB)) end return startB, endB, prioriteB, elementB elseif element.type == "not" then local startA, endA = self:ComputeBool(element.a) @@ -643,7 +639,7 @@ function OvaleBestAction:Compute(element) return startA, endA, 3, result elseif element.type == "lua" then local ret = loadstring(element.lua)() - Ovale:Log("lua "..nilstring(ret)) + Ovale:Log("lua "..tostring(ret)) if not element.result then element.result = { type = "value" } end @@ -727,9 +723,9 @@ function OvaleBestAction:Compute(element) if bestElement.params then id = bestElement.params[1] end - Ovale:Print("group best action "..tostring(id).." remains "..meilleurTempsFils..","..nilstring(bestEnd).." ["..element.nodeId.."]") + Ovale:Print("group best action "..tostring(id).." remains "..meilleurTempsFils..","..tostring(bestEnd).." ["..element.nodeId.."]") else - Ovale:Print("group no best action returns "..meilleurTempsFils..","..nilstring(bestEnd).." ["..element.nodeId.."]") + Ovale:Print("group no best action returns "..meilleurTempsFils..","..tostring(bestEnd).." ["..element.nodeId.."]") end end return meilleurTempsFils, bestEnd, meilleurePrioriteFils, bestElement diff --git a/OvaleCondition.lua b/OvaleCondition.lua index fece9bb..61f3261 100644 --- a/OvaleCondition.lua +++ b/OvaleCondition.lua @@ -42,6 +42,8 @@ local savedHealth = {} local targetGUID = {} local lastSPD = {} +local tostring = tostring + -- -- @@ -154,14 +156,6 @@ local function addOrSubTime(time1, operator, duration) end end -local function nilstring(text) - if text == nil then - return "nil" - else - return text - end -end - -- Get the expiration time of a debuff -- that can be on any unit except the target -- Returns the first to expires, the last to expires @@ -335,7 +329,7 @@ local function GetTargetAura(condition, target) end if Ovale.trace then - Ovale:Print("GetTargetAura = start=".. nilstring(aura.start) .. " end="..nilstring(aura.ending).." stacks=" ..nilstring(aura.stacks).."/"..stacks) + Ovale:Print("GetTargetAura = start=".. tostring(aura.start) .. " end="..tostring(aura.ending).." stacks=" ..tostring(aura.stacks).."/"..stacks) end if (not condition.mine or (aura.mine and condition.mine==1) or (not aura.mine and condition.mine==0)) and aura.stacks>=stacks then @@ -522,8 +516,8 @@ OvaleCondition.conditions= local start, ending = GetTargetAura(condition, getTarget(condition.target)) local timeBefore = avecHate(condition[2], condition.haste) if Ovale.trace then - Ovale:Print("timeBefore = " .. nilstring(timeBefore)) - Ovale:Print("start = " .. nilstring(ending)) + Ovale:Print("timeBefore = " .. tostring(timeBefore)) + Ovale:Print("start = " .. tostring(ending)) end return addTime(ending, -timeBefore) end, diff --git a/OvaleState.lua b/OvaleState.lua index 9a44677..bc97ece 100644 --- a/OvaleState.lua +++ b/OvaleState.lua @@ -35,18 +35,9 @@ OvaleState.lastSpellId = nil -- local UnitGUID = UnitGUID +local tostring = tostring -- --- -local function nilstring(text) - if text == nil then - return "nil" - else - return text - end -end --- - -- function OvaleState:StartNewFrame() self.maintenant = GetTime() @@ -253,7 +244,7 @@ function OvaleState:AddSpellToStack(spellId, startCast, endCast, nextCast, nocd, local buffAura = self:GetAura("player", newSpellInfo.buffnocd, true) if self.traceAura then if buffAura then - Ovale:Print("buffAura stacks = "..buffAura.stacks.." start="..nilstring(buffAura.start).." ending = "..nilstring(buffAura.ending)) + Ovale:Print("buffAura stacks = "..buffAura.stacks.." start="..tostring(buffAura.start).." ending = "..tostring(buffAura.ending)) Ovale:Print("startCast = "..startCast) else Ovale:Print("buffAura = nil") -- 1.7.9.5