From 808b6c45d2fdfb8aaedf604152a4f5973e45f846 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 29 Oct 2024 09:15:49 +0100 Subject: [PATCH] Less spammy doom counter message --- src/core/DoomCounter.ttslua | 6 ++++-- src/core/DoomInPlayCounter.ttslua | 18 ++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/core/DoomCounter.ttslua b/src/core/DoomCounter.ttslua index 987ae969..07dc1c01 100644 --- a/src/core/DoomCounter.ttslua +++ b/src/core/DoomCounter.ttslua @@ -89,8 +89,10 @@ function broadcastDoom(val) local doomInPlayCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomInPlayCounter") if doomInPlayCounter and md.subtractDoomInPlay then - doomInPlayCounter.call("toggleSubtractDoom", true) - broadcastToAll("Right-click the small 'Doom in Play' counter and select 'Toggle Doom Mode' to change this.") + local previousState = doomInPlayCounter.call("toggleSubtractDoom", true) + if previousState == false then + broadcastToAll("Right-click the small 'Doom in Play' counter and select 'Toggle Doom Mode' to change this.") + end end local doomInPlay = doomInPlayCounter and doomInPlayCounter.call("getDoomCount") or 0 local totalDoom = val + doomInPlay diff --git a/src/core/DoomInPlayCounter.ttslua b/src/core/DoomInPlayCounter.ttslua index cfca2055..aa678f5d 100644 --- a/src/core/DoomInPlayCounter.ttslua +++ b/src/core/DoomInPlayCounter.ttslua @@ -5,16 +5,10 @@ local ZONE, TRASH local doomURL = "https://i.imgur.com/EoL7yaZ.png" local IGNORE_TAG = "DoomCounter_ignore" local TOTAL_PLAY_AREA = { - upperLeft = { - x = -9, - z = -35 - }, - lowerRight = { - x = -60, - z = 35 - } + upperLeft = { x = -9, z = -35 }, + lowerRight = { x = -60, z = 35 } } -local subtractDoom = false +local subtractDoom = false function updateSave() self.script_state = JSON.encode(subtractDoom) @@ -23,7 +17,7 @@ end -- create button, context menu and start loop function onLoad(savedData) if savedData and savedData ~= "" then - subtractDoom = JSON.decode(savedData) + subtractDoom = JSON.decode(savedData) or false end self.addContextMenuItem("Toggle Doom Mode", function() toggleSubtractDoom() end) @@ -52,9 +46,9 @@ function toggleSubtractDoom(override) else subtractDoom = not subtractDoom end - + -- early exit if nothing was changed - if previousState == subtractDoom then return end + if previousState == subtractDoom then return previousState end updateSave()