Handling for removed mats

This commit is contained in:
Chr1Z93 2024-09-18 19:14:25 +02:00
parent c20d747921
commit 822ba9fb42

View File

@ -1,3 +1,4 @@
local guidReferenceApi = require("core/GUIDReferenceApi")
local playermatApi = require("playermat/PlayermatApi") local playermatApi = require("playermat/PlayermatApi")
fullButtonData = { fullButtonData = {
@ -185,7 +186,6 @@ end
-- XML button creation -- XML button creation
function createXmlButtonHelper(ui, params) function createXmlButtonHelper(ui, params)
local guid = self.getGUID()
local xml = findTagWithId(ui, params.id) local xml = findTagWithId(ui, params.id)
-- add basic image -- add basic image
@ -202,7 +202,7 @@ function createXmlButtonHelper(ui, params)
table.insert(xml.children, { table.insert(xml.children, {
tag = "button", tag = "button",
attributes = { attributes = {
onClick = guid .. "/buttonClicked", onClick = self.getGUID() .. "/buttonClicked",
id = d.id, id = d.id,
height = d.height, height = d.height,
width = d.width, width = d.width,
@ -311,10 +311,18 @@ function loadCamera(player, camera)
matColor = camera matColor = camera
end end
-- if mat is removed, end here
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
if mat == nil then
printToColor("This playermat seems to be removed.", player.color)
return
end
-- dynamic view of the play area -- dynamic view of the play area
if index == 2 then if index == 2 then
-- search the scripting zone on the play area for objects -- search the scripting zone on the play area for objects
local bounds = getDynamicViewBounds(getObjectFromGUID("a2f932").getObjects()) local zone = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone")
local bounds = getDynamicViewBounds(zone.getObjects())
lookHere = { lookHere = {
position = { bounds.middleX, 1.55, bounds.middleZ }, position = { bounds.middleX, 1.55, bounds.middleZ },