addded feedback to instruction generator
This commit is contained in:
parent
2c7bba922f
commit
aabaf52d96
@ -3,6 +3,7 @@ local searchLib = require("util/SearchLib")
|
|||||||
local idList = {}
|
local idList = {}
|
||||||
|
|
||||||
function onLoad()
|
function onLoad()
|
||||||
|
-- "generate" button
|
||||||
local buttonParameters = {}
|
local buttonParameters = {}
|
||||||
buttonParameters.function_owner = self
|
buttonParameters.function_owner = self
|
||||||
buttonParameters.height = 200
|
buttonParameters.height = 200
|
||||||
@ -13,6 +14,7 @@ function onLoad()
|
|||||||
buttonParameters.position = { 0, 0.06, 1.55 }
|
buttonParameters.position = { 0, 0.06, 1.55 }
|
||||||
self.createButton(buttonParameters)
|
self.createButton(buttonParameters)
|
||||||
|
|
||||||
|
-- "output" text field
|
||||||
local inputParameters = {}
|
local inputParameters = {}
|
||||||
inputParameters.label = "Click button above"
|
inputParameters.label = "Click button above"
|
||||||
inputParameters.input_function = "none"
|
inputParameters.input_function = "none"
|
||||||
@ -24,14 +26,15 @@ function onLoad()
|
|||||||
self.createInput(inputParameters)
|
self.createInput(inputParameters)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- generates a string for the ArkhamDB deck notes that will instruct the deck import to add the specified cards
|
||||||
function generate(_, playerColor)
|
function generate(_, playerColor)
|
||||||
idList = {}
|
idList = {}
|
||||||
for _, obj in ipairs(searchLib.onObject(self, "isCardOrDeck")) do
|
for _, obj in ipairs(searchLib.onObject(self, "isCardOrDeck")) do
|
||||||
if obj.type == "Card" then
|
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
|
elseif obj.type == "Deck" then
|
||||||
for _, deepObj in ipairs(obj.getData().ContainedObjects) do
|
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
|
end
|
||||||
end
|
end
|
||||||
@ -66,11 +69,13 @@ function getIdFromData(metadata)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function processCard(metadata, name)
|
function processCard(metadata, name, playerColor)
|
||||||
if metadata then
|
if metadata then
|
||||||
local id = getIdFromData(metadata)
|
local id = getIdFromData(metadata)
|
||||||
if id then
|
if id then
|
||||||
table.insert(idList, {id = id, name = name})
|
table.insert(idList, {id = id, name = name})
|
||||||
|
else
|
||||||
|
broadcastToColor("Couldn't get ID for " .. name .. ".", playerColor, "Red")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user