updated hider to actually remove mats (no respawning yet)

This commit is contained in:
Chr1Z93 2024-01-01 11:50:38 +01:00
parent 6b0a889724
commit 8a2822d84e
6 changed files with 19 additions and 97 deletions

View File

@ -172,7 +172,6 @@
"TokenSpawnTracker.e3ffc9",
"TokenSource.124381",
"GameData.3dbe47",
"PlayermatClickInterceptor.3dbe55",
"SCEDTour.0e5aa8",
"InstructionGenerator.240522",
"PlayerCards.2d30ee",

View File

@ -22,7 +22,7 @@
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/2115061845796985108/F0ADB7094641DA966FFA3AF0CC6987D33D2D9591/",
"WidthScale": 0
},
"Description": "Use the buttons to show / hide a playermat.",
"Description": "Use the buttons to hide playermat(s).",
"DragSelectable": true,
"GMNotes": "",
"GUID": "a758b2",

View File

@ -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": ""
}

View File

@ -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

View File

@ -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)
if not objects.Playermat then return 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")
local pos = objects.Playermat.getPosition()
local mod = (pos.y > 0) and -2 or 2
-- 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))
obj.destruct()
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
-- remove mat owned objects
for _, obj in pairs(objects) do
obj.destruct()
end
end
local interceptor = getObjectFromGUID("3dbe55")
interceptor.call("setState", state)
end)
end

View File

@ -39,7 +39,7 @@
</Cell>
<Cell>
<Panel>
<Button onClick="onClick_hideShow(White)">Show / Hide</Button>
<Button onClick="onClick_hide(White)">Hide</Button>
</Panel>
</Cell>
</Row>
@ -49,7 +49,7 @@
</Cell>
<Cell>
<Panel>
<Button onClick="onClick_hideShow(Orange)">Show / Hide</Button>
<Button onClick="onClick_hide(Orange)">Hide</Button>
</Panel>
</Cell>
</Row>
@ -59,7 +59,7 @@
</Cell>
<Cell>
<Panel>
<Button onClick="onClick_hideShow(Green)">Show / Hide</Button>
<Button onClick="onClick_hide(Green)">Hide</Button>
</Panel>
</Cell>
</Row>
@ -69,7 +69,7 @@
</Cell>
<Cell>
<Panel>
<Button onClick="onClick_hideShow(Red)">Show / Hide</Button>
<Button onClick="onClick_hide(Red)">Hide</Button>
</Panel>
</Cell>
</Row>