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