From 20e0f8075b5f8ca09291338f1b1cfc97b5df6e81 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 22 Dec 2022 13:18:45 +0100 Subject: [PATCH] bugfix for handhelper, error handling for missing barrel --- objects/LuaScriptState.luascriptstate | 2 +- src/core/Global.ttslua | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/objects/LuaScriptState.luascriptstate b/objects/LuaScriptState.luascriptstate index 3a990518..f685f165 100644 --- a/objects/LuaScriptState.luascriptstate +++ b/objects/LuaScriptState.luascriptstate @@ -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}} diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 0964b638..ff4433c3 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -885,14 +885,22 @@ end ---@param name String Name of the object that should be copied ---@param position Position Desired position of the object 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 = { position = position, callback_function = function(object) - if name == "Hand Helper" then - Wait.time(function() object.call("externalColorChange", color) end, 1) - elseif name == "Token Arranger" then - Wait.time(function() object.call("layout") end, 1) - end + if name == "Hand Helper" then + Wait.time(function() object.call("externalColorChange", color) end, 0.1) + elseif name == "Token Arranger" then + Wait.time(function() object.call("layout") end, 0.1) + end end } @@ -901,7 +909,7 @@ function spawnHelperObject(name, position, rotation, color) spawnTable.rotation = rotation end - for _, obj in ipairs(getObjectFromGUID(BARREL_GUID).getData().ContainedObjects) do + for _, obj in ipairs(barrel.getData().ContainedObjects) do if obj["Nickname"] == name then spawnTable.data = obj return spawnObjectData(spawnTable) @@ -955,7 +963,7 @@ function onClick_defaultSettings() useClueClickers = false, showTokenArranger = false, showCleanUpHelper = false, - showHandHelper = false, + showHandHelper = {}, showChaosBagManager = false, showNavigationOverlay = false }