SCED/src/core/MasterClueCounter.ttslua

42 lines
1.2 KiB
Plaintext
Raw Normal View History

2023-09-09 06:54:36 -04:00
local playmatApi = require("playermat/PlaymatApi")
-- variables are intentionally global to be accessible
2022-12-08 08:27:55 -05:00
count = 0
2022-12-14 18:18:10 -05:00
useClickableCounters = false
2022-12-08 08:27:55 -05:00
2022-12-14 18:18:10 -05:00
function onSave() return JSON.encode(useClickableCounters) end
2022-12-08 08:27:55 -05:00
function onLoad(savedData)
if savedData ~= nil then
2022-12-14 18:18:10 -05:00
useClickableCounters = JSON.decode(savedData)
2022-12-08 08:27:55 -05:00
end
2022-12-01 08:39:22 -05:00
self.createButton({
label = "0",
click_function = "removeAllPlayerClues",
2022-12-08 08:27:55 -05:00
tooltip = "Click here to remove all collected clues",
2022-12-01 08:39:22 -05:00
function_owner = self,
position = { 0, 0.06, 0 },
height = 900,
width = 900,
scale = { 1.5, 1.5, 1.5 },
2023-09-09 06:54:36 -04:00
font_size = 650,
font_color = { 0, 0, 0, 100 },
2022-12-01 08:39:22 -05:00
color = { 0, 0, 0, 0 }
})
loopID = Wait.time(sumClues, 2, -1)
end
2022-12-08 08:27:55 -05:00
-- removes all player clues by calling the respective function from the counting bowls / clickers
function removeAllPlayerClues()
2022-12-08 08:27:55 -05:00
printToAll(count .. " clue(s) from playermats removed.", "White")
2023-09-09 06:54:36 -04:00
playmatApi.removeClues("All")
2022-12-08 08:27:55 -05:00
self.editButton({ index = 0, label = "0" })
end
2022-12-08 08:27:55 -05:00
-- gets the counted values from the counting bowls / clickers and sums them up
2022-12-01 08:39:22 -05:00
function sumClues()
2023-09-09 06:54:36 -04:00
count = playmatApi.getClueCount(useClickableCounters, "All")
2022-12-01 08:39:22 -05:00
self.editButton({ index = 0, label = tostring(count) })
end