From 8394e7de3f27ceed4ab4d483c2f82750f4002906 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 13 Feb 2024 12:04:29 +0100 Subject: [PATCH] updated clue counter for kate --- src/playermat/ClueCounter.ttslua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/playermat/ClueCounter.ttslua b/src/playermat/ClueCounter.ttslua index 5bd1fef8..3f75f750 100644 --- a/src/playermat/ClueCounter.ttslua +++ b/src/playermat/ClueCounter.ttslua @@ -1,6 +1,11 @@ +local guidReferenceApi = require("core/GUIDReferenceApi") +local playmatApi = require("playermat/PlaymatApi") local searchLib = require("util/SearchLib") + exposedValue = 0 +local playmat + function onLoad() self.createButton({ label = "", @@ -12,10 +17,16 @@ function onLoad() font_color = { 0, 0, 0 }, font_size = 2000 }) - loopID = Wait.time(countItems, 1.5, -1) + + -- get closest playmat + local matColor = playmatApi.getMatColorByPosition(self.getPosition()) + playmat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat") + + -- start loop + Wait.time(countItems, 1.5, -1) end --- Activated once per second, counts items in bowls +-- activated once per second, counts clues on the playmat function countItems() local totalValue = 0 for _, item in ipairs(getClues()) do @@ -32,5 +43,5 @@ function removeAllClues(trash) end function getClues() - return searchLib.inArea(self.getPosition(), self.getRotation(), { 2, 1, 2 }, "isClue") + return searchLib.onObject(playmat, "isClue") end