SCED/src/core/MasterClueCounter.ttslua

78 lines
1.8 KiB
Plaintext
Raw Normal View History

2022-12-01 08:39:22 -05:00
local clueCounters = {}
local clueCounterGUIDS = {
"37be78",
"1769ed",
"032300",
"d86b7c"
}
2022-12-08 08:27:55 -05:00
local clueClickers = {}
local clueClickerGUIDS = {
"db85d6",
"3f22e5",
"891403",
"4111de"
}
count = 0
clickableCounters = false
function onSave() return JSON.encode(clickableCounters) end
function onLoad(savedData)
if savedData ~= nil then
clickableCounters = JSON.decode(savedData)
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 },
font_size = 600,
font_color = { 1, 1, 1, 100 },
color = { 0, 0, 0, 0 }
})
2022-12-08 08:27:55 -05:00
-- loading object references to the clue counters / clickers via GUID
2022-12-01 08:39:22 -05:00
for i = 1, 4 do
clueCounters[i] = getObjectFromGUID(clueCounterGUIDS[i])
2022-12-08 08:27:55 -05:00
clueClickers[i] = getObjectFromGUID(clueClickerGUIDS[i])
2022-12-01 08:39:22 -05:00
end
2022-12-01 08:39:22 -05:00
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")
if not clickableCounters then
for i = 1, 4 do
clueCounters[i].call("removeAllClues")
end
else
for i = 1, 4 do
clueClickers[i].call("updateVal", 0)
end
2022-12-01 08:39:22 -05:00
end
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()
2022-12-08 08:27:55 -05:00
count = 0
if not clickableCounters then
for i = 1, 4 do
count = count + tonumber(clueCounters[i].getVar("exposedValue"))
end
else
for i = 1, 4 do
count = count + tonumber(clueClickers[i].getVar("val"))
end
end
2022-12-01 08:39:22 -05:00
self.editButton({ index = 0, label = tostring(count) })
end