2024-02-13 12:04:29 +01:00
|
|
|
local guidReferenceApi = require("core/GUIDReferenceApi")
|
|
|
|
local playmatApi = require("playermat/PlaymatApi")
|
2023-12-11 18:11:04 +01:00
|
|
|
local searchLib = require("util/SearchLib")
|
2024-02-13 12:04:29 +01:00
|
|
|
|
2022-12-08 12:46:22 +01:00
|
|
|
exposedValue = 0
|
2021-10-06 20:37:31 -07:00
|
|
|
|
2024-02-13 12:04:29 +01:00
|
|
|
local playmat
|
|
|
|
|
2021-10-06 20:37:31 -07:00
|
|
|
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
|
|
|
|
})
|
2024-02-13 12:04:29 +01:00
|
|
|
|
|
|
|
-- get closest playmat
|
|
|
|
local matColor = playmatApi.getMatColorByPosition(self.getPosition())
|
|
|
|
playmat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
|
|
|
|
|
|
|
|
-- start loop
|
|
|
|
Wait.time(countItems, 1.5, -1)
|
2021-10-06 20:37:31 -07:00
|
|
|
end
|
|
|
|
|
2024-02-13 12:04:29 +01:00
|
|
|
-- activated once per second, counts clues on the playmat
|
2021-10-06 20:37:31 -07:00
|
|
|
function countItems()
|
2023-01-08 22:48:34 +01:00
|
|
|
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 })
|
2021-10-06 20:37:31 -07:00
|
|
|
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)
|
2021-10-06 20:37:31 -07:00
|
|
|
end
|
2023-12-11 18:11:04 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function getClues()
|
2024-02-13 12:04:29 +01:00
|
|
|
return searchLib.onObject(playmat, "isClue")
|
2023-12-11 18:11:04 +01:00
|
|
|
end
|