Merge pull request #918 from dscarpac/fix-toggle
Bug Fix: Doom counter toggle
This commit is contained in:
commit
ab5ea6e60e
@ -90,7 +90,7 @@ function broadcastDoom(val)
|
|||||||
local doomInPlayCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomInPlayCounter")
|
local doomInPlayCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomInPlayCounter")
|
||||||
if doomInPlayCounter and md.subtractDoomInPlay then
|
if doomInPlayCounter and md.subtractDoomInPlay then
|
||||||
doomInPlayCounter.call("toggleSubtractDoom", true)
|
doomInPlayCounter.call("toggleSubtractDoom", true)
|
||||||
printToAll("Right-click the small 'Doom in Play' counter and select 'Toggle Doom Mode' to change this.")
|
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 doomInPlay = doomInPlayCounter and doomInPlayCounter.call("getDoomCount") or 0
|
||||||
local totalDoom = val + doomInPlay
|
local totalDoom = val + doomInPlay
|
||||||
@ -102,7 +102,7 @@ function broadcastDoom(val)
|
|||||||
table.insert(broadcastParts, " doom on the agenda (")
|
table.insert(broadcastParts, " doom on the agenda (")
|
||||||
|
|
||||||
-- add the middle part
|
-- add the middle part
|
||||||
if doomThreshold then
|
if doomThreshold - mod > 0 then
|
||||||
-- maybe add color if threshold is reached
|
-- maybe add color if threshold is reached
|
||||||
if totalDoom >= doomThreshold then
|
if totalDoom >= doomThreshold then
|
||||||
table.insert(broadcastParts, "[" .. Color.fromString("Red"):toHex() .. "]")
|
table.insert(broadcastParts, "[" .. Color.fromString("Red"):toHex() .. "]")
|
||||||
@ -118,8 +118,12 @@ function broadcastDoom(val)
|
|||||||
|
|
||||||
table.insert(broadcastParts, " total)")
|
table.insert(broadcastParts, " total)")
|
||||||
else
|
else
|
||||||
table.insert(broadcastParts, val + math.abs(doomInPlay))
|
table.insert(broadcastParts, val + doomInPlay)
|
||||||
table.insert(broadcastParts, " in play)")
|
if doomInPlay < 0 then
|
||||||
|
table.insert(broadcastParts, " total)")
|
||||||
|
else
|
||||||
|
table.insert(broadcastParts, " in play)")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
broadcastToAll(table.concat(broadcastParts, ""))
|
broadcastToAll(table.concat(broadcastParts, ""))
|
||||||
|
@ -26,7 +26,7 @@ function onLoad(savedData)
|
|||||||
subtractDoom = JSON.decode(savedData)
|
subtractDoom = JSON.decode(savedData)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.addContextMenuItem("Toggle Doom Mode", toggleSubtractDoom)
|
self.addContextMenuItem("Toggle Doom Mode", function() toggleSubtractDoom() end)
|
||||||
self.createButton({
|
self.createButton({
|
||||||
label = "0",
|
label = "0",
|
||||||
click_function = "none",
|
click_function = "none",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user