SCED/src/core/MasterClueCounter.ttslua
2022-12-15 02:26:38 +01:00

40 lines
1.1 KiB
Plaintext

count = 0
useClickableCounters = false
local playmatAPI = require("playermat/PlaymatApi")
function onSave() return JSON.encode(useClickableCounters) end
function onLoad(savedData)
if savedData ~= nil then
useClickableCounters = JSON.decode(savedData)
end
self.createButton({
label = "0",
click_function = "removeAllPlayerClues",
tooltip = "Click here to remove all collected clues",
function_owner = self,
position = { 0, 0.06, 0 },
height = 900,
width = 900,
scale = { 1.5, 1.5, 1.5 },
font_size = 600,
font_color = { 1, 1, 1, 100 },
color = { 0, 0, 0, 0 }
})
loopID = Wait.time(sumClues, 2, -1)
end
-- removes all player clues by calling the respective function from the counting bowls / clickers
function removeAllPlayerClues()
printToAll(count .. " clue(s) from playermats removed.", "White")
playmatAPI.removeClues("All")
self.editButton({ index = 0, label = "0" })
end
-- gets the counted values from the counting bowls / clickers and sums them up
function sumClues()
count = playmatAPI.getClueCount(useClickableCounters, "All")
self.editButton({ index = 0, label = tostring(count) })
end