bugfixing
This commit is contained in:
parent
496c4c84ca
commit
f1c0a8e922
@ -33,7 +33,7 @@
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "require(\"playercards/cards/TheChthonianStone3\")",
|
||||
"LuaScript": "require(\"playercards/cards/TheChthonianStone\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Card",
|
||||
|
@ -53,27 +53,27 @@ As a nice reminder the XML button takes on the Frost color and icon with the tex
|
||||
|
||||
local isHelperEnabled = false
|
||||
|
||||
function onSave()
|
||||
return JSON.encode(isHelperEnabled)
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode({ isHelperEnabled = isHelperEnabled })
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
createHelperXML()
|
||||
|
||||
self.addTag("CardWithHelper")
|
||||
if savedData and savedData ~= "" then
|
||||
isHelperEnabled = JSON.decode(savedData)
|
||||
local loadedData = JSON.decode(savedData)
|
||||
isHelperEnabled = loadedData.isHelperEnabled
|
||||
end
|
||||
|
||||
checkOptionPanel()
|
||||
createHelperXML()
|
||||
updateDisplay()
|
||||
end
|
||||
|
||||
function createHelperXML()
|
||||
isHelperEnabled = true
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Clear Helper", deleteButton)
|
||||
local xmlTable = { {
|
||||
tag = "Button",
|
||||
attributes = {
|
||||
active = "false",
|
||||
id = "Helper",
|
||||
height = buttonHeight or 450,
|
||||
width = buttonWidth or 1400,
|
||||
rotation = buttonRotation or "0 0 180",
|
||||
@ -103,11 +103,3 @@ function triggerXMLTokenLabelCreation()
|
||||
RETURN_TO_POOL = RETURN_TO_POOL
|
||||
})
|
||||
end
|
||||
|
||||
-- Delete button
|
||||
function deleteButton()
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Enable Helper", makeXMLButton)
|
||||
self.UI.setXml("")
|
||||
isHelperEnabled = false
|
||||
end
|
||||
|
@ -22,10 +22,12 @@ function toggleHelper()
|
||||
updateDisplay()
|
||||
end
|
||||
|
||||
-- updates the visibility and performs some common operations like adding a tag
|
||||
-- updates the visibility and calls events (after a small delay to allow XML being set)
|
||||
function updateDisplay()
|
||||
self.addTag("CardWithHelper")
|
||||
Wait.frames(actualDisplayUpdate, 5)
|
||||
end
|
||||
|
||||
function actualDisplayUpdate()
|
||||
if isHelperEnabled then
|
||||
self.UI.show("Helper")
|
||||
self.clearContextMenu()
|
||||
|
@ -14,6 +14,7 @@ function updateSave()
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
self.addTag("CardWithHelper")
|
||||
if savedData and savedData ~= "" then
|
||||
local loadedData = JSON.decode(savedData)
|
||||
isHelperEnabled = loadedData.isHelperEnabled
|
||||
@ -23,7 +24,7 @@ function onLoad(savedData)
|
||||
updateDisplay()
|
||||
end
|
||||
|
||||
-- hide buttons and stop monitoing
|
||||
-- hide buttons and stop monitoring
|
||||
function shutOff()
|
||||
self.UI.setAttribute("inactives", "active", false)
|
||||
self.UI.setAttribute("actives", "active", false)
|
||||
|
@ -19,7 +19,7 @@ initialButtonPosition = buttonParameters.position.z
|
||||
local verticalOffset = 0.325
|
||||
|
||||
-- list of customizable labels
|
||||
local customizableList = {
|
||||
local customizableList = {
|
||||
'Run out of cards in hand',
|
||||
'Take damage/horror',
|
||||
'Discard treachery/enemy',
|
||||
@ -27,24 +27,41 @@ local customizableList = {
|
||||
}
|
||||
|
||||
-- index of the currently selected button (0-indexed from the top)
|
||||
local activeButtonIndex
|
||||
local activeButtonIndex = -1
|
||||
local isHelperEnabled = false
|
||||
local hypothesisList = {}
|
||||
|
||||
function onSave()
|
||||
return JSON.encode(activeButtonIndex)
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode({
|
||||
isHelperEnabled = isHelperEnabled,
|
||||
activeButtonIndex = activeButtonIndex
|
||||
})
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
self.addContextMenuItem("Enable Helper", createButtons)
|
||||
self.addContextMenuItem("Clear Helper", deleteButtons)
|
||||
|
||||
activeButtonIndex = JSON.decode(savedData)
|
||||
if activeButtonIndex and activeButtonIndex ~= "" then
|
||||
local tempButtonIndex = activeButtonIndex
|
||||
createButtons()
|
||||
if tempButtonIndex >= 0 then
|
||||
selectButton(tempButtonIndex)
|
||||
end
|
||||
self.addTag("CardWithHelper")
|
||||
if savedData and savedData ~= "" then
|
||||
local loadedData = JSON.decode(savedData)
|
||||
isHelperEnabled = loadedData.isHelperEnabled
|
||||
activeButtonIndex = loadedData.activeButtonIndex
|
||||
end
|
||||
checkOptionPanel()
|
||||
updateDisplay()
|
||||
|
||||
if activeButtonIndex > 0 then
|
||||
selectButton(activeButtonIndex)
|
||||
end
|
||||
end
|
||||
|
||||
function initialize()
|
||||
createButtons()
|
||||
end
|
||||
|
||||
function shutOff()
|
||||
self.clearButtons()
|
||||
|
||||
-- reset the z position
|
||||
buttonParameters.position.z = initialButtonPosition
|
||||
end
|
||||
|
||||
-- marks a button as active
|
||||
@ -61,23 +78,10 @@ function selectButton(index)
|
||||
end
|
||||
end
|
||||
|
||||
function deleteButtons()
|
||||
self.clearButtons()
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Enable Helper", createButtons)
|
||||
buttonParameters.position.z = initialButtonPosition -- reset the z position
|
||||
end
|
||||
|
||||
-- Create buttons based on the button parameters
|
||||
function createButtons()
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Clear Helper", deleteButtons)
|
||||
|
||||
-- reset the list in case of addition of checkboxes or Refine
|
||||
hypothesisList = {
|
||||
'Succeed by 3 or more',
|
||||
'Fail by 2 or more'
|
||||
}
|
||||
hypothesisList = { 'Succeed by 3 or more', 'Fail by 2 or more' }
|
||||
|
||||
-- set activeButtonIndex to restore state onLoad ("-1" -> nothing selected)
|
||||
activeButtonIndex = -1
|
||||
@ -93,9 +97,9 @@ function createButtons()
|
||||
end
|
||||
|
||||
for i, label in ipairs(hypothesisList) do
|
||||
buttonParameters.label = label
|
||||
buttonParameters.click_function = "selectButton" .. i
|
||||
self.setVar(buttonParameters.click_function, function() selectButton(i - 1) end)
|
||||
buttonParameters.label = label
|
||||
self.createButton(buttonParameters)
|
||||
buttonParameters.position.z = buttonParameters.position.z + verticalOffset
|
||||
end
|
||||
|
@ -1,8 +0,0 @@
|
||||
VALID_TOKENS = {
|
||||
["Skull"] = true,
|
||||
["Cultist"] = true,
|
||||
["Tablet"] = true,
|
||||
["Elder Thing"] = true,
|
||||
}
|
||||
|
||||
require("playercards/CardsThatSealTokens")
|
@ -58,4 +58,4 @@
|
||||
</Cell>
|
||||
</Row>
|
||||
</TableLayout>
|
||||
</Helper>
|
||||
</Panel>
|
||||
|
Loading…
Reference in New Issue
Block a user