SCED/src/playermat/ClueCounter.ttslua

37 lines
849 B
Plaintext
Raw Normal View History

2023-12-11 18:11:04 +01:00
local searchLib = require("util/SearchLib")
2022-12-08 12:46:22 +01:00
exposedValue = 0
function onLoad()
2022-12-08 12:46:22 +01:00
self.createButton({
label = "",
2023-10-02 13:51:10 +02:00
click_function = "countItems",
2022-12-08 12:46:22 +01:00
function_owner = self,
position = { 0, 0.1, 0 },
height = 0,
width = 0,
font_color = { 0, 0, 0 },
font_size = 2000
})
2023-12-11 18:11:04 +01:00
loopID = Wait.time(countItems, 1.5, -1)
end
2022-12-08 12:46:22 +01:00
-- Activated once per second, counts items in bowls
function countItems()
local totalValue = 0
2023-12-11 18:11:04 +01:00
for _, item in ipairs(getClues()) do
totalValue = totalValue + math.abs(item.getQuantity())
2022-12-08 12:46:22 +01:00
end
exposedValue = totalValue
self.editButton({ index = 0, label = totalValue })
end
2023-10-02 13:51:10 +02:00
function removeAllClues(trash)
2023-12-11 18:11:04 +01:00
for _, obj in ipairs(getClues()) do
2023-10-02 13:51:10 +02:00
trash.putObject(obj)
end
2023-12-11 18:11:04 +01:00
end
function getClues()
return searchLib.inArea(self.getPosition(), self.getRotation(), { 2, 1, 2 }, "isClue")
end