diff --git a/objects/Clues.3f22e5.json b/objects/Clues.3f22e5.json index 17a50489..22fbf643 100644 --- a/objects/Clues.3f22e5.json +++ b/objects/Clues.3f22e5.json @@ -46,7 +46,7 @@ "Tooltip": false, "Transform": { "posX": -59.426, - "posY": 1.3, + "posY": -1, "posZ": -22.721, "rotX": 0, "rotY": 280, diff --git a/objects/Clues.4111de.json b/objects/Clues.4111de.json index 97c69558..6de3db8f 100644 --- a/objects/Clues.4111de.json +++ b/objects/Clues.4111de.json @@ -46,7 +46,7 @@ "Tooltip": false, "Transform": { "posX": -23.89, - "posY": 1.3, + "posY": -1, "posZ": -30.977, "rotX": 0, "rotY": 190, diff --git a/objects/Clues.891403.json b/objects/Clues.891403.json index 32174201..0e1d3a62 100644 --- a/objects/Clues.891403.json +++ b/objects/Clues.891403.json @@ -46,7 +46,7 @@ "Tooltip": false, "Transform": { "posX": -36.87, - "posY": 1.3, + "posY": -1, "posZ": 30.977, "rotX": 0, "rotY": 10, diff --git a/objects/Clues.db85d6.json b/objects/Clues.db85d6.json index 902a38f5..47e6d5c0 100644 --- a/objects/Clues.db85d6.json +++ b/objects/Clues.db85d6.json @@ -46,7 +46,7 @@ "Tooltip": false, "Transform": { "posX": -59.426, - "posY": 1.3, + "posY": -1, "posZ": 9.395, "rotX": 0, "rotY": 280, diff --git a/objects/Fan-MadeAccessories.aa8b38/PlayermatHider.a758b2.json b/objects/Fan-MadeAccessories.aa8b38/PlayermatHider.a758b2.json index 595c5900..55c4a3e4 100644 --- a/objects/Fan-MadeAccessories.aa8b38/PlayermatHider.a758b2.json +++ b/objects/Fan-MadeAccessories.aa8b38/PlayermatHider.a758b2.json @@ -56,5 +56,5 @@ "scaleZ": 3 }, "Value": 0, - "XmlUI": "" + "XmlUI": "\u003cInclude src=\"accessories/PlayermatHider.xml\"/\u003e" } \ No newline at end of file diff --git a/src/accessories/PlayermatHider.ttslua b/src/accessories/PlayermatHider.ttslua index 7bfdca49..16766cff 100644 --- a/src/accessories/PlayermatHider.ttslua +++ b/src/accessories/PlayermatHider.ttslua @@ -1,7 +1,41 @@ local guidReferenceApi = require("core/GUIDReferenceApi") +local objects -function onClick_hideShow(player, value, id) - log(player) - log(value) - log(id) +function onClick_hideShow(player, matColor) + objects = guidReferenceApi.getObjectsByOwner(matColor) + local actionTokens = searchMat(objects.Playermat.positionToWorld({-1.1, 0.05, -0.27}), {4, 1, 1}, isActionToken) + local pos = objects.Playermat.getPosition() + local mod = (pos.y > 0) and -3 or 3 + + -- move all objects + for _, obj in pairs(objects) do + obj.setPosition(obj.getPosition() + Vector(0, mod, 0)) + end + + -- move action tokens + for _, obj in ipairs(actionTokens) do + obj.setLock(pos.y > 0) + obj.setPosition(obj.getPosition() + Vector(0, mod, 0)) + end +end + +function isActionToken(x) return x.getDescription() == 'Action Token' end + +function searchMat(origin, size, filter) + local searchResult = Physics.cast({ + origin = origin, + direction = { 0, 1, 0 }, + orientation = objects.Playermat.getRotation(), + type = 3, + size = size, + max_distance = 0 + }) + + local objList = {} + for _, v in ipairs(searchResult) do + if not filter or (filter and filter(v.hit_object)) then + table.insert(objList, v.hit_object) + end + end + return objList end diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 1f62619b..23e337d2 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -858,11 +858,15 @@ function showDrawButton(visible) end end --- Spawns / destroys a clickable clue counter for this playmat with the correct amount of clues ----@param showCounter Boolean Whether the clickable clue counter should be present +-- shows / hides a clickable clue counter for this playmat and sets the correct amount of clues +---@param showCounter Boolean Whether the clickable clue counter should be visible function clickableClues(showCounter) local clickerPos = ownedObjects.ClickableClueCounter.getPosition() local clueCount = 0 + + -- move clue counters + local modY = showcounter and -2.52 or 2.52 + ownedObjects.ClickableClueCounter.setPosition(clickerPos + Vector(0, modY, 0)) if showCounter then -- current clue count @@ -873,18 +877,10 @@ function clickableClues(showCounter) -- set value for clue clickers ownedObjects.ClickableClueCounter.call("updateVal", clueCount) - - -- move clue counters up - clickerPos.y = 1.52 - ownedObjects.ClickableClueCounter.setPosition(clickerPos) else -- current clue count clueCount = ownedObjects.ClickableClueCounter.getVar("val") - -- move clue counters down - clickerPos.y = 1.3 - ownedObjects.ClickableClueCounter.setPosition(clickerPos) - -- spawn clues local pos = self.positionToWorld({x = -1.12, y = 0.05, z = 0.7}) for i = 1, clueCount do diff --git a/xml/accessories/PlayermatHider.xml b/xml/accessories/PlayermatHider.xml index f960c747..239a1a79 100644 --- a/xml/accessories/PlayermatHider.xml +++ b/xml/accessories/PlayermatHider.xml @@ -1,35 +1,77 @@ - + + + + + + - + Playermat 2 (Orange) - + + + - + Playermat 3 (Green) - + + + - + Playermat 4 (Red) - + + + \ No newline at end of file