"Added TraceMode to Bastion class, introduced Trace function, and updated Ticker and tickFrame to use Trace instead of Debug."

CiscOH Bellic 2 years ago
parent 8c5ce32c5e
commit 30c937f669
  1. 28
      src/_bastion.lua

@ -2,7 +2,8 @@ local Tinkr = ...
---@class Bastion ---@class Bastion
local Bastion = { local Bastion = {
DebugMode = false DebugMode = false,
TraceMode = false,
} }
Bastion.__index = Bastion Bastion.__index = Bastion
@ -219,6 +220,18 @@ function Bastion:Debug(...)
print(str) print(str)
end end
function Bastion:Trace(...)
if not Bastion.TraceMode then
return
end
local args = {...}
local str = "|cFFDF6520[Bastion]|r |cFFFFFFFF"
for i = 1, #args do
str = str .. tostring(args[i]) .. " "
end
print(str)
end
local Command = Bastion.Command:New('bastion') local Command = Bastion.Command:New('bastion')
Command:Register('toggle', 'Toggle bastion on/off', function() Command:Register('toggle', 'Toggle bastion on/off', function()
@ -239,6 +252,15 @@ Command:Register('debug', 'Toggle debug mode on/off', function()
end end
end) end)
Command:Register('trace', 'Toggle trace mode on/off', function()
Bastion.TraceMode = not Bastion.TraceMode
if Bastion.TraceMode then
Bastion:Print("Trace mode enabled")
else
Bastion:Print("Trace mode disabled")
end
end)
Command:Register('dumpspells', 'Dump spells to a file', function() Command:Register('dumpspells', 'Dump spells to a file', function()
local i = 1 local i = 1
local rand = math.random(100000, 999999) local rand = math.random(100000, 999999)
@ -399,7 +421,7 @@ function Bastion:GetTick()
end end
function Bastion:Ticker() function Bastion:Ticker()
Bastion:Debug("Bastion:Ticker run") Bastion:Trace("Bastion:Ticker run")
if not Bastion.CombatTimer:IsRunning() and UnitAffectingCombat("player") then if not Bastion.CombatTimer:IsRunning() and UnitAffectingCombat("player") then
Bastion.CombatTimer:Start() Bastion.CombatTimer:Start()
elseif Bastion.CombatTimer:IsRunning() and not UnitAffectingCombat("player") then elseif Bastion.CombatTimer:IsRunning() and not UnitAffectingCombat("player") then
@ -421,7 +443,7 @@ tickFrame:HookScript("OnUpdate", function(self, elapsed)
timeElapsed = timeElapsed - Bastion.tickRate timeElapsed = timeElapsed - Bastion.tickRate
Bastion:Ticker() Bastion:Ticker()
end end
Bastion:Debug("TickRate: " .. Bastion.tickRate) Bastion:Trace("TickRate: " .. Bastion.tickRate)
Bastion.tickRate = Bastion:GetTickRate() Bastion.tickRate = Bastion:GetTickRate()
timeElapsed = 0 timeElapsed = 0

Loading…
Cancel
Save