From 39c07c22d0a93d01ac978ba9c569fd07e9ac4983 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 11 Oct 2023 19:49:27 +0200 Subject: [PATCH] moved script and added handling for empty bags --- .../Subject5U-21Helper.1335e8.json | 2 +- .../UnderworldMarketHelper.3650ea.json | 2 +- .../accessories/Subject5U-21Helper.ttslua | 12 ++++++++---- .../accessories/UnderworldMarketHelper.ttslua | 0 4 files changed, 10 insertions(+), 6 deletions(-) rename objects/Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.ttslua => src/accessories/Subject5U-21Helper.ttslua (85%) rename objects/Fan-MadeAccessories.aa8b38/UnderworldMarketHelper.3650ea.ttslua => src/accessories/UnderworldMarketHelper.ttslua (100%) diff --git a/objects/Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.json b/objects/Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.json index f61e0e0d..a273d326 100644 --- a/objects/Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.json +++ b/objects/Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.json @@ -49,8 +49,8 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, + "LuaScript": "require(\"accessories/Subject5U-21Helper\")", "LuaScriptState": "", - "LuaScript_path": "Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.ttslua", "MeasureMovement": false, "Name": "Custom_Tile", "Nickname": "Subject 5U-21 Helper", diff --git a/objects/Fan-MadeAccessories.aa8b38/UnderworldMarketHelper.3650ea.json b/objects/Fan-MadeAccessories.aa8b38/UnderworldMarketHelper.3650ea.json index 2f8145ec..3da26de4 100644 --- a/objects/Fan-MadeAccessories.aa8b38/UnderworldMarketHelper.3650ea.json +++ b/objects/Fan-MadeAccessories.aa8b38/UnderworldMarketHelper.3650ea.json @@ -34,8 +34,8 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, + "LuaScript": "require(\"accessories/UnderworldMarketHelper\")", "LuaScriptState": "", - "LuaScript_path": "Fan-MadeAccessories.aa8b38/UnderworldMarketHelper.3650ea.ttslua", "MaterialIndex": -1, "MeasureMovement": false, "MeshIndex": -1, diff --git a/objects/Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.ttslua b/src/accessories/Subject5U-21Helper.ttslua similarity index 85% rename from objects/Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.ttslua rename to src/accessories/Subject5U-21Helper.ttslua index 064004e8..7c01d914 100644 --- a/objects/Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.ttslua +++ b/src/accessories/Subject5U-21Helper.ttslua @@ -91,10 +91,14 @@ function getNotesFromCardsAndContainers() notes = JSON.decode(obj.getGMNotes()) or {} table.insert(notesList, notes) elseif obj.type == "Bag" or obj.type == "Deck" then - for _, deepObj in ipairs(obj.getData().ContainedObjects) do - if deepObj.Name == "Card" or deepObj.Name == "CardCustom" then - notes = JSON.decode(deepObj.GMNotes) or {} - table.insert(notesList, notes) + -- check if there are actually objects contained and loop through them + local containedObjects = obj.getData().ContainedObjects + if containedObjects then + for _, deepObj in ipairs(containedObjects) do + if deepObj.Name == "Card" or deepObj.Name == "CardCustom" then + notes = JSON.decode(deepObj.GMNotes) or {} + table.insert(notesList, notes) + end end end end diff --git a/objects/Fan-MadeAccessories.aa8b38/UnderworldMarketHelper.3650ea.ttslua b/src/accessories/UnderworldMarketHelper.ttslua similarity index 100% rename from objects/Fan-MadeAccessories.aa8b38/UnderworldMarketHelper.3650ea.ttslua rename to src/accessories/UnderworldMarketHelper.ttslua