From 30c937f669f4eeed9879eccfd92ddea8091c959c Mon Sep 17 00:00:00 2001 From: CiscOH Bellic Date: Fri, 26 Jul 2024 23:00:46 -0400 Subject: [PATCH] "Added TraceMode to Bastion class, introduced Trace function, and updated Ticker and tickFrame to use Trace instead of Debug." --- src/_bastion.lua | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/_bastion.lua b/src/_bastion.lua index 267f4aa..26add4e 100644 --- a/src/_bastion.lua +++ b/src/_bastion.lua @@ -2,7 +2,8 @@ local Tinkr = ... ---@class Bastion local Bastion = { - DebugMode = false + DebugMode = false, + TraceMode = false, } Bastion.__index = Bastion @@ -219,6 +220,18 @@ function Bastion:Debug(...) print(str) 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') Command:Register('toggle', 'Toggle bastion on/off', function() @@ -239,6 +252,15 @@ Command:Register('debug', 'Toggle debug mode on/off', function() 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() local i = 1 local rand = math.random(100000, 999999) @@ -399,7 +421,7 @@ function Bastion:GetTick() end function Bastion:Ticker() - Bastion:Debug("Bastion:Ticker run") + Bastion:Trace("Bastion:Ticker run") if not Bastion.CombatTimer:IsRunning() and UnitAffectingCombat("player") then Bastion.CombatTimer:Start() elseif Bastion.CombatTimer:IsRunning() and not UnitAffectingCombat("player") then @@ -421,7 +443,7 @@ tickFrame:HookScript("OnUpdate", function(self, elapsed) timeElapsed = timeElapsed - Bastion.tickRate Bastion:Ticker() end - Bastion:Debug("TickRate: " .. Bastion.tickRate) + Bastion:Trace("TickRate: " .. Bastion.tickRate) Bastion.tickRate = Bastion:GetTickRate() timeElapsed = 0