bugfix for handhelper, error handling for missing barrel

This commit is contained in:
Chr1Z93 2022-12-22 13:18:45 +01:00
parent d5f04cf465
commit 20e0f8075b
2 changed files with 16 additions and 8 deletions

View File

@ -1 +1 @@
{"optionPanel":{"showChaosBagManager":false,"showCleanUpHelper":false,"showDrawButton":false,"showHandHelper":false,"showNavigationOverlay":false,"showTokenArranger":false,"useClueClickers":false,"useSnapTags":true}} {"optionPanel":{"showChaosBagManager":false,"showCleanUpHelper":false,"showDrawButton":false,"showHandHelper":{},"showNavigationOverlay":false,"showTokenArranger":false,"useClueClickers":false,"useSnapTags":true}}

View File

@ -885,14 +885,22 @@ end
---@param name String Name of the object that should be copied ---@param name String Name of the object that should be copied
---@param position Position Desired position of the object ---@param position Position Desired position of the object
function spawnHelperObject(name, position, rotation, color) function spawnHelperObject(name, position, rotation, color)
local barrel = getObjectFromGUID(BARREL_GUID)
-- error handling for missing barrel
if not barrel then
broadcastToAll("'Barrel' with fan-made accessories could not be found!", "Red")
return
end
local spawnTable = { local spawnTable = {
position = position, position = position,
callback_function = function(object) callback_function = function(object)
if name == "Hand Helper" then if name == "Hand Helper" then
Wait.time(function() object.call("externalColorChange", color) end, 1) Wait.time(function() object.call("externalColorChange", color) end, 0.1)
elseif name == "Token Arranger" then elseif name == "Token Arranger" then
Wait.time(function() object.call("layout") end, 1) Wait.time(function() object.call("layout") end, 0.1)
end end
end end
} }
@ -901,7 +909,7 @@ function spawnHelperObject(name, position, rotation, color)
spawnTable.rotation = rotation spawnTable.rotation = rotation
end end
for _, obj in ipairs(getObjectFromGUID(BARREL_GUID).getData().ContainedObjects) do for _, obj in ipairs(barrel.getData().ContainedObjects) do
if obj["Nickname"] == name then if obj["Nickname"] == name then
spawnTable.data = obj spawnTable.data = obj
return spawnObjectData(spawnTable) return spawnObjectData(spawnTable)
@ -955,7 +963,7 @@ function onClick_defaultSettings()
useClueClickers = false, useClueClickers = false,
showTokenArranger = false, showTokenArranger = false,
showCleanUpHelper = false, showCleanUpHelper = false,
showHandHelper = false, showHandHelper = {},
showChaosBagManager = false, showChaosBagManager = false,
showNavigationOverlay = false showNavigationOverlay = false
} }