From aabaf52d96439ff399b2bf0f61057cbca3d6b97d Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 16 Feb 2024 10:38:58 +0100 Subject: [PATCH] addded feedback to instruction generator --- src/arkhamdb/InstructionGenerator.ttslua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/arkhamdb/InstructionGenerator.ttslua b/src/arkhamdb/InstructionGenerator.ttslua index 1593b171..2be595ea 100644 --- a/src/arkhamdb/InstructionGenerator.ttslua +++ b/src/arkhamdb/InstructionGenerator.ttslua @@ -3,6 +3,7 @@ local searchLib = require("util/SearchLib") local idList = {} function onLoad() + -- "generate" button local buttonParameters = {} buttonParameters.function_owner = self buttonParameters.height = 200 @@ -13,6 +14,7 @@ function onLoad() buttonParameters.position = { 0, 0.06, 1.55 } self.createButton(buttonParameters) + -- "output" text field local inputParameters = {} inputParameters.label = "Click button above" inputParameters.input_function = "none" @@ -24,14 +26,15 @@ function onLoad() self.createInput(inputParameters) end +-- generates a string for the ArkhamDB deck notes that will instruct the deck import to add the specified cards function generate(_, playerColor) idList = {} for _, obj in ipairs(searchLib.onObject(self, "isCardOrDeck")) do if obj.type == "Card" then - processCard(JSON.decode(obj.getGMNotes()), obj.getName()) + processCard(JSON.decode(obj.getGMNotes()), obj.getName(), playerColor) elseif obj.type == "Deck" then for _, deepObj in ipairs(obj.getData().ContainedObjects) do - processCard(JSON.decode(deepObj.GMNotes), deepObj.Nickname) + processCard(JSON.decode(deepObj.GMNotes), deepObj.Nickname, playerColor) end end end @@ -66,11 +69,13 @@ function getIdFromData(metadata) end end -function processCard(metadata, name) +function processCard(metadata, name, playerColor) if metadata then local id = getIdFromData(metadata) if id then table.insert(idList, {id = id, name = name}) + else + broadcastToColor("Couldn't get ID for " .. name .. ".", playerColor, "Red") end end end