diff --git a/config.json b/config.json
index 06ac5882..e5f1c9f6 100644
--- a/config.json
+++ b/config.json
@@ -173,7 +173,6 @@
"TokenSpawnTracker.e3ffc9",
"TokenSource.124381",
"GameData.3dbe47",
- "PlayermatClickInterceptor.3dbe55",
"SCEDTour.0e5aa8",
"InstructionGenerator.240522",
"PlayerCards.2d30ee",
diff --git a/objects/LuaScriptState.luascriptstate b/objects/LuaScriptState.luascriptstate
index 727ccd58..c26d46ba 100644
--- a/objects/LuaScriptState.luascriptstate
+++ b/objects/LuaScriptState.luascriptstate
@@ -1 +1 @@
-{"acknowledgedUpgradeVersions":[],"optionPanel":{"cardLanguage":"en","changePlayAreaImage":false,"playAreaConnectionColor":{"a":1,"b":0.4,"g":0.4,"r":0.4},"playAreaConnections":true,"playAreaSnapTags":true,"showAttachmentHelper":false,"showCleanUpHelper":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":[],"showPlayermatHider":false,"showSearchAssistant":[],"showTitleSplash":true,"useClueClickers":false,"useResourceCounters":"disabled","useSnapTags":true}}
+{"acknowledgedUpgradeVersions":[],"optionPanel":{"cardLanguage":"en","changePlayAreaImage":false,"playAreaConnectionColor":{"a":1,"b":0.4,"g":0.4,"r":0.4},"playAreaConnections":true,"playAreaSnapTags":true,"showAttachmentHelper":false,"showCleanUpHelper":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":[],"showSearchAssistant":[],"showTitleSplash":true,"useClueClickers":false,"useResourceCounters":"disabled","useSnapTags":true}}
diff --git a/objects/OptionPanelSource.830bd0.json b/objects/OptionPanelSource.830bd0.json
index 7e9310a5..56ede1b5 100644
--- a/objects/OptionPanelSource.830bd0.json
+++ b/objects/OptionPanelSource.830bd0.json
@@ -17,7 +17,6 @@
"CYOACampaignGuides.e87ea2",
"AttachmentHelper.7f4976",
"SearchAssistant.17aed0",
- "PlayermatHider.a758b2",
"HandHelper.450688",
"DisplacementTool.0f1374",
"CleanUpHelper.26cf4b"
diff --git a/objects/OptionPanelSource.830bd0/PlayermatHider.a758b2.json b/objects/OptionPanelSource.830bd0/PlayermatHider.a758b2.json
deleted file mode 100644
index ec43653b..00000000
--- a/objects/OptionPanelSource.830bd0/PlayermatHider.a758b2.json
+++ /dev/null
@@ -1,60 +0,0 @@
-{
- "AltLookAngle": {
- "x": 0,
- "y": 0,
- "z": 0
- },
- "Autoraise": true,
- "ColorDiffuse": {
- "b": 1,
- "g": 1,
- "r": 1
- },
- "CustomImage": {
- "CustomTile": {
- "Stackable": false,
- "Stretch": true,
- "Thickness": 0.1,
- "Type": 3
- },
- "ImageScalar": 1,
- "ImageSecondaryURL": "",
- "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2115061845796985108/F0ADB7094641DA966FFA3AF0CC6987D33D2D9591/",
- "WidthScale": 0
- },
- "Description": "Use the buttons to show / hide a playermat.",
- "DragSelectable": true,
- "GMNotes": "",
- "GUID": "a758b2",
- "Grid": true,
- "GridProjection": false,
- "Hands": false,
- "HideWhenFaceDown": false,
- "IgnoreFoW": false,
- "LayoutGroupSortIndex": 0,
- "Locked": false,
- "LuaScript": "require(\"accessories/PlayermatHider\")",
- "LuaScriptState": "",
- "MeasureMovement": false,
- "Name": "Custom_Tile",
- "Nickname": "Playermat Hider",
- "Snap": true,
- "Sticky": true,
- "Tags": [
- "CleanUpHelper_ignore"
- ],
- "Tooltip": true,
- "Transform": {
- "posX": 0,
- "posY": 2,
- "posZ": 0,
- "rotX": 0,
- "rotY": 270,
- "rotZ": 0,
- "scaleX": 3,
- "scaleY": 1,
- "scaleZ": 3
- },
- "Value": 0,
- "XmlUI": "\u003cInclude src=\"accessories/PlayermatHider.xml\"/\u003e"
-}
diff --git a/objects/PlayermatClickInterceptor.3dbe55.json b/objects/PlayermatClickInterceptor.3dbe55.json
deleted file mode 100644
index 1c8b76fc..00000000
--- a/objects/PlayermatClickInterceptor.3dbe55.json
+++ /dev/null
@@ -1,50 +0,0 @@
-{
- "AltLookAngle": {
- "x": 0,
- "y": 0,
- "z": 0
- },
- "Autoraise": true,
- "ColorDiffuse": {
- "b": 0,
- "g": 0,
- "r": 0
- },
- "Description": "This object is used to hide playmats beneath the table.",
- "DragSelectable": true,
- "GMNotes": "",
- "GUID": "3dbe55",
- "Grid": true,
- "GridProjection": false,
- "Hands": false,
- "HideWhenFaceDown": false,
- "IgnoreFoW": false,
- "LayoutGroupSortIndex": 0,
- "Locked": true,
- "LuaScriptState": "false",
- "LuaScript_path": "PlayermatClickInterceptor.3dbe55.ttslua",
- "MeasureMovement": false,
- "Name": "BlockSquare",
- "Nickname": "PlayermatClickInterceptor",
- "Snap": true,
- "Sticky": true,
- "Tags": [
- "CameraZoom_ignore",
- "CleanUpHelper_ignore",
- "displacement_excluded"
- ],
- "Tooltip": false,
- "Transform": {
- "posX": -27.94,
- "posY": -0.5,
- "posZ": 0,
- "rotX": 0,
- "rotY": 270,
- "rotZ": 0,
- "scaleX": 84,
- "scaleY": 1.5,
- "scaleZ": 70
- },
- "Value": 0,
- "XmlUI": ""
-}
diff --git a/objects/PlayermatClickInterceptor.3dbe55.ttslua b/objects/PlayermatClickInterceptor.3dbe55.ttslua
deleted file mode 100644
index 93877ebf..00000000
--- a/objects/PlayermatClickInterceptor.3dbe55.ttslua
+++ /dev/null
@@ -1,15 +0,0 @@
-local interactable = false
-
-function onSave() return JSON.encode(interactable) end
-
-function onLoad(savedData)
- if savedData and savedData ~= "" then
- interactable = JSON.decode(savedData)
- end
- self.interactable = interactable
-end
-
-function setState(state)
- interactable = state
- self.interactable = interactable
-end
diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua
index d6d18ada..9cf93302 100644
--- a/src/accessories/CleanUpHelper.ttslua
+++ b/src/accessories/CleanUpHelper.ttslua
@@ -280,13 +280,14 @@ function tidyPlayerMatCoroutine()
local trash = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], "Trash")
if trash == nil then
printToAll("Trashcan for " .. COLORS[i] .. " playmat could not be found!", "Red")
- return 1
+ break
end
local objList
if i < 5 then
objList = playmatApi.searchAroundPlaymat(COLORS[i])
else
+ -- Victory Display + Mythos Area
objList = searchLib.inArea({ -2, 2, 10 }, { 0, 270, 0 }, { 55, 1, 13.5 })
end
diff --git a/src/accessories/PlayermatHider.ttslua b/src/accessories/PlayermatHider.ttslua
index a48f0648..b4185b6c 100644
--- a/src/accessories/PlayermatHider.ttslua
+++ b/src/accessories/PlayermatHider.ttslua
@@ -1,33 +1,21 @@
local guidReferenceApi = require("core/GUIDReferenceApi")
local playmatApi = require("playermat/PlaymatApi")
-function onClick_hideShow(player, matColor)
+function onClick_hide(player, matColor)
local objects = guidReferenceApi.getObjectsByOwner(matColor)
- local actionTokens = playmatApi.searchAroundPlaymat(matColor, "isActionToken")
- local pos = objects.Playermat.getPosition()
- local mod = (pos.y > 0) and -2 or 2
+ if not objects.Playermat then return end
- -- move all objects
- for _, obj in pairs(objects) do
- obj.setPosition(obj.getPosition() + Vector(0, mod, 0))
- end
+ player.showConfirmDialog("Really remove this playmat and related objects? This can't be reversed.",
+ function()
+ -- remove action tokens
+ local actionTokens = playmatApi.searchAroundPlaymat(matColor, "isActionToken")
+ for _, obj in ipairs(actionTokens) do
+ obj.destruct()
+ end
- -- move action tokens
- for _, obj in ipairs(actionTokens) do
- obj.setLock(pos.y > 0)
- obj.setPosition(obj.getPosition() + Vector(0, mod, 0))
- end
-
- -- set state of interceptor block
- local allMats = guidReferenceApi.getObjectsByType("Playermat")
- local state = false
- for owner, mat in pairs(allMats) do
- if mat.getPosition().y < 0 then
- state = true
- break
- end
- end
-
- local interceptor = getObjectFromGUID("3dbe55")
- interceptor.call("setState", state)
+ -- remove mat owned objects
+ for _, obj in pairs(objects) do
+ obj.destruct()
+ end
+ end)
end
diff --git a/src/core/GUIDReferenceApi.ttslua b/src/core/GUIDReferenceApi.ttslua
index 3728eb09..63db9288 100644
--- a/src/core/GUIDReferenceApi.ttslua
+++ b/src/core/GUIDReferenceApi.ttslua
@@ -24,5 +24,17 @@ do
return getGuidHandler().call("getObjectsByOwner", owner)
end
+ -- sends new information to the reference handler to edit the main index
+ ---@param owner String Parent of the object
+ ---@param type String Type of the object
+ ---@param guid String GUID of the object
+ GUIDReferenceApi.editIndex = function(owner, type, guid)
+ return getGuidHandler().call("editIndex", {
+ owner = owner,
+ type = type,
+ guid = guid
+ })
+ end
+
return GUIDReferenceApi
end
diff --git a/src/core/GUIDReferenceHandler.ttslua b/src/core/GUIDReferenceHandler.ttslua
index a9ab8503..c5ab07e2 100644
--- a/src/core/GUIDReferenceHandler.ttslua
+++ b/src/core/GUIDReferenceHandler.ttslua
@@ -91,12 +91,43 @@ local GuidReferences = {
}
}
+local editsToIndex = {
+ White = {},
+ Orange = {},
+ Green = {},
+ Red = {},
+ Mythos = {}
+}
+
+-- save function to keep edits to the index
+function onSave() return JSON.encode({ editsToIndex = editsToIndex }) end
+
+-- load function to restore edits to the index
+function onLoad(savedData)
+ if savedData and savedData ~= "" then
+ local loadedData = JSON.decode(savedData)
+ editsToIndex = loadedData.editsToIndex
+ updateMainIndex()
+ end
+end
+
+-- merges the main index and the edits
+function updateMainIndex()
+ for owner, subTable in pairs(editsToIndex) do
+ for type, guid in pairs(subTable) do
+ GuidReferences[owner][type] = guid
+ end
+ end
+end
+
+-- returns an object reference for the requested owner and type
function getObjectByOwnerAndType(params)
local owner = params.owner or "Mythos"
local type = params.type
return getObjectFromGUID(GuidReferences[owner][type])
end
+-- returns a list of objects for the requested type
function getObjectsByType(type)
local objList = {}
for owner, objects in pairs(GuidReferences) do
@@ -108,6 +139,7 @@ function getObjectsByType(type)
return objList
end
+-- returns a list of objects for the requested owner
function getObjectsByOwner(owner)
local objList = {}
for type, guid in pairs(GuidReferences[owner]) do
@@ -118,3 +150,9 @@ function getObjectsByOwner(owner)
end
return objList
end
+
+-- makes an edit to the main index
+function editIndex(params)
+ editsToIndex[params.owner][params.type] = params.guid
+ updateMainIndex()
+end
diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua
index 23a336ba..9ad1d120 100644
--- a/src/core/GameKeyHandler.ttslua
+++ b/src/core/GameKeyHandler.ttslua
@@ -253,7 +253,7 @@ function switchSeat(playerColor, direction)
end
-- swap color
- navigationOverlayApi.loadCamera(playerColor, usedColors[index])
+ navigationOverlayApi.loadCamera(Player[playerColor], usedColors[index])
end
-- takes a clue from a location, player needs to hover the clue directly or the location
diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua
index 8ee04751..a8f6d737 100644
--- a/src/core/Global.ttslua
+++ b/src/core/Global.ttslua
@@ -1215,6 +1215,45 @@ function returnResourceCounterId(name)
end
end
+-- called by the playermat removal selection dropdown
+function playermatRemovalSelected(player, selectedIndex, id)
+ if selectedIndex == "0" then return end
+
+ local matColorList = { "White", "Orange", "Green", "Red" }
+ local matColor = matColorList[tonumber(selectedIndex)]
+ local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
+
+ if mat then
+ -- confirmation dialog about deletion
+ player.pingTable(mat.getPosition())
+ player.showConfirmDialog("Do you really want to remove " .. matColor .. "'s playermat and related objects? This can't be reversed.", function() removePlayermat(matColor) end)
+ else
+ -- info dialog that it is already deleted
+ player.showInfoDialog(matColor .. "'s playermat has already been removed.")
+ end
+
+ -- set selected value back to first option
+ UI.setAttribute(id, "value", 0)
+end
+
+-- removes a playermat and all related objects from play
+---@param matColor String Color of the playermat to remove
+function removePlayermat(matColor)
+ local matObjects = guidReferenceApi.getObjectsByOwner(matColor)
+ if not matObjects.Playermat then return end
+
+ -- remove action tokens
+ local actionTokens = playmatApi.searchAroundPlaymat(matColor, "isActionToken")
+ for _, obj in ipairs(actionTokens) do
+ obj.destruct()
+ end
+
+ -- remove mat owned objects
+ for _, obj in pairs(matObjects) do
+ obj.destruct()
+ end
+end
+
-- sets the option panel to the correct state (corresponding to 'optionPanel')
function updateOptionPanelState()
for id, optionValue in pairs(optionPanel) do
@@ -1289,22 +1328,22 @@ function applyOptionPanelChange(id, state)
-- option: Show hand helper for each player
elseif id == "showHandHelper" then
- for i, color in ipairs(MAT_COLORS) do
- local pos = playmatApi.transformLocalPosition({0.05, 0, -1.182}, color)
- local rot = playmatApi.returnRotation(color)
- optionPanel[id][i] = spawnOrRemoveHelper(state, "Hand Helper", pos, rot)
+ local helperName = "Hand Helper"
+ local spawnData = playmatApi.getHelperSpawnData("All", helperName)
+ local i = 0
+ for color, data in pairs(spawnData) do
+ i = i + 1
+ optionPanel[id][i] = spawnOrRemoveHelper(state, helperName, data.position, data.rotation, color)
end
- -- option: Show playermat hider
- elseif id == "showPlayermatHider" then
- optionPanel[id] = spawnOrRemoveHelper(state, "Playermat Hider", {-48, 1.6, 46})
-
-- option: Show search assistant for each player
elseif id == "showSearchAssistant" then
- for i, color in ipairs(MAT_COLORS) do
- local pos = playmatApi.transformLocalPosition({-0.3, 0, -1.182}, color)
- local rot = playmatApi.returnRotation(color)
- optionPanel[id][i] = spawnOrRemoveHelper(state, "Search Assistant", pos, rot)
+ local helperName = "Search Assistant"
+ local spawnData = playmatApi.getHelperSpawnData("All", helperName)
+ local i = 0
+ for color, data in pairs(spawnData) do
+ i = i + 1
+ optionPanel[id][i] = spawnOrRemoveHelper(state, helperName, data.position, data.rotation, color)
end
-- option: Show attachment helper
@@ -1326,13 +1365,17 @@ end
---@param name String Name of the helper object
---@param position Vector Position of the object (where it will spawn)
---@param rotation Vector Rotation of the object for spawning (default: {0, 270, 0})
+---@param owner String Owner of the object (defaults to "Mythos")
---@return. GUID of the spawnedObj (or nil if object was removed)
-function spawnOrRemoveHelper(state, name, position, rotation)
+function spawnOrRemoveHelper(state, name, position, rotation, owner)
if (type(state) == "table" and #state == 0) then
return removeHelperObject(name)
elseif state then
Player.getPlayers()[1].pingTable(position)
- return spawnHelperObject(name, position, rotation).getGUID()
+ local spawnedGUID = spawnHelperObject(name, position, rotation).getGUID()
+ local cleanName = name:gsub("%s+", "")
+ guidReferenceApi.editIndex(owner or "Mythos", cleanName, spawnedGUID)
+ return spawnedGUID
else
return removeHelperObject(name)
end
@@ -1376,7 +1419,6 @@ function removeHelperObject(name)
local referenceTable = {
["Clean Up Helper"] = "showCleanUpHelper",
["Hand Helper"] = "showHandHelper",
- ["Playermat Hider"] = "showPlayermatHider",
["Search Assistant"] = "showSearchAssistant",
["Displacement Tool"] = "showDisplacementTool",
["Attachment Helper"] = "showAttachmentHelper",
@@ -1431,7 +1473,6 @@ function onClick_defaultSettings()
showDisplacementTool = false,
showDrawButton = false,
showHandHelper = {},
- showPlayermatHider = false,
showSearchAssistant = {},
showTitleSplash = true,
useClueClickers = false,
diff --git a/src/core/NavigationOverlayApi.ttslua b/src/core/NavigationOverlayApi.ttslua
index 9a94d04e..adfed08d 100644
--- a/src/core/NavigationOverlayApi.ttslua
+++ b/src/core/NavigationOverlayApi.ttslua
@@ -25,9 +25,9 @@ do
-- loads the specified camera for a player
---@param player TTSPlayerInstance Player whose camera should be moved
---@param camera Variant If number: Index of the camera view to load | If string: Color of the playermat to swap to
- NavigationOverlayApi.loadCamera = function(playerColor, camera)
+ NavigationOverlayApi.loadCamera = function(player, camera)
getNOHandler().call("loadCameraFromApi", {
- playerColor = playerColor,
+ player = player,
camera = camera
})
end
diff --git a/src/core/NavigationOverlayHandler.ttslua b/src/core/NavigationOverlayHandler.ttslua
index 55f2de16..f20beedc 100644
--- a/src/core/NavigationOverlayHandler.ttslua
+++ b/src/core/NavigationOverlayHandler.ttslua
@@ -292,7 +292,7 @@ function getDynamicViewBounds(objList)
end
function loadCameraFromApi(params)
- loadCamera(Player[params.playerColor], params.camera)
+ loadCamera(params.player, params.camera)
end
-- loads the specified camera for a player
diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua
index 1e067bc7..ed4a5366 100644
--- a/src/playermat/PlaymatApi.ttslua
+++ b/src/playermat/PlaymatApi.ttslua
@@ -96,6 +96,26 @@ do
end
end
+ -- Returns a table with spawn data (position and rotation) for a helper object
+ ---@param matColor String Color of the playmat - White, Orange, Green, Red or All
+ ---@param helperName String Name of the helper object
+ PlaymatApi.getHelperSpawnData = function(matColor, helperName)
+ local resultTable = {}
+ local localPositionTable = {
+ ["Hand Helper"] = {0.05, 0, -1.182},
+ ["Search Assistant"] = {-0.3, 0, -1.182}
+ }
+
+ for color, mat in pairs(getMatForColor(matColor)) do
+ resultTable[color] = {
+ position = mat.positionToWorld(localPositionTable[helperName]),
+ rotation = mat.getRotation()
+ }
+ end
+ return resultTable
+ end
+
+
-- Triggers the Upkeep for the requested playmat
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
---@param playerColor String Color of the calling player (for messages)
diff --git a/xml/Global/OptionPanel.xml b/xml/Global/OptionPanel.xml
index 9400f31d..fe3b38d1 100644
--- a/xml/Global/OptionPanel.xml
+++ b/xml/Global/OptionPanel.xml
@@ -297,6 +297,28 @@
+
+
+
+
+ Remove a playermat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -351,7 +373,7 @@
+ tooltip="This allows moving all objects on the main play area
in a chosen direction.">
Displacement Tool
@@ -377,20 +399,6 @@
-
-
-
-
- Playmat Hider
-
-
-
-
-
-
-
diff --git a/xml/accessories/PlayermatHider.xml b/xml/accessories/PlayermatHider.xml
deleted file mode 100644
index ffc70b81..00000000
--- a/xml/accessories/PlayermatHider.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
- Playermat Hider
-
-
-
-
- Playermat 1 (White)
-
-
-
-
-
-
-
-
-
- Playermat 2 (Orange)
-
-
-
-
-
-
-
-
-
- Playermat 3 (Green)
-
-
-
-
-
-
-
-
-
- Playermat 4 (Red)
-
-
-
-
-
-
-
-
\ No newline at end of file