2024-06-23 13:49:56 -04:00
|
|
|
local playermatApi = require("playermat/PlayermatApi")
|
2023-09-09 06:54:36 -04:00
|
|
|
|
|
|
|
-- 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)
|
2024-03-25 12:36:03 -04:00
|
|
|
if savedData and savedData ~= "" then
|
2022-12-14 18:18:10 -05:00
|
|
|
useClickableCounters = JSON.decode(savedData)
|
2022-12-08 08:27:55 -05:00
|
|
|
end
|
2024-03-25 12:36:03 -04:00
|
|
|
|
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,
|
2023-10-19 11:07:05 -04:00
|
|
|
font_color = { 1, 1, 1, 100 },
|
2022-12-01 08:39:22 -05:00
|
|
|
color = { 0, 0, 0, 0 }
|
|
|
|
})
|
2024-03-25 12:36:03 -04:00
|
|
|
|
2023-10-01 19:36:49 -04:00
|
|
|
Wait.time(sumClues, 2, -1)
|
2021-10-06 23:37:31 -04:00
|
|
|
end
|
|
|
|
|
2022-12-08 08:27:55 -05:00
|
|
|
-- removes all player clues by calling the respective function from the counting bowls / clickers
|
2021-10-06 23:37:31 -04:00
|
|
|
function removeAllPlayerClues()
|
2022-12-08 08:27:55 -05:00
|
|
|
printToAll(count .. " clue(s) from playermats removed.", "White")
|
2024-06-23 13:49:56 -04:00
|
|
|
playermatApi.removeClues("All")
|
2022-12-08 08:27:55 -05:00
|
|
|
self.editButton({ index = 0, label = "0" })
|
2021-10-06 23:37:31 -04:00
|
|
|
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()
|
2024-06-23 13:49:56 -04:00
|
|
|
count = playermatApi.getClueCount(useClickableCounters, "All")
|
2022-12-01 08:39:22 -05:00
|
|
|
self.editButton({ index = 0, label = tostring(count) })
|
2021-10-06 23:37:31 -04:00
|
|
|
end
|