SCED/src/core/MasterClueCounter.ttslua
2024-06-23 19:49:56 +02:00

43 lines
1.2 KiB
Plaintext

local playermatApi = require("playermat/PlayermatApi")
-- variables are intentionally global to be accessible
count = 0
useClickableCounters = false
function onSave() return JSON.encode(useClickableCounters) end
function onLoad(savedData)
if savedData and savedData ~= "" 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 = 650,
font_color = { 1, 1, 1, 100 },
color = { 0, 0, 0, 0 }
})
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")
playermatApi.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 = playermatApi.getClueCount(useClickableCounters, "All")
self.editButton({ index = 0, label = tostring(count) })
end