Merge pull request #787 from dscarpac/nkosi-helper
Added helper to Nkosi
This commit is contained in:
commit
93a37b3308
@ -1,4 +1,9 @@
|
|||||||
require("playercards/CardsWithHelper")
|
require("playercards/CardsWithHelper")
|
||||||
|
|
||||||
|
-- intentionally global
|
||||||
|
hasXML = false
|
||||||
|
isHelperEnabled = false
|
||||||
|
|
||||||
local chaosBagApi = require("chaosbag/ChaosBagApi")
|
local chaosBagApi = require("chaosbag/ChaosBagApi")
|
||||||
|
|
||||||
-- XML background color for each token
|
-- XML background color for each token
|
||||||
@ -14,18 +19,25 @@ local tokenColor = {
|
|||||||
[""] = "#77674DE6"
|
[""] = "#77674DE6"
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSave()
|
function updateSave()
|
||||||
return JSON.encode(sigil)
|
self.script_state = JSON.encode({
|
||||||
|
isHelperEnabled = isHelperEnabled,
|
||||||
|
sigil = sigil
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
self.addContextMenuItem("Enable Helper", chooseSigil)
|
if savedData and savedData ~= "" then
|
||||||
sigil = JSON.decode(savedData)
|
local loadedData = JSON.decode(savedData)
|
||||||
|
isHelperEnabled = loadedData.isHelperEnabled
|
||||||
|
sigil = loadedData.sigil
|
||||||
if sigil and sigil ~= nil then
|
if sigil and sigil ~= nil then
|
||||||
makeXMLButton()
|
makeXMLButton()
|
||||||
self.clearContextMenu()
|
|
||||||
self.addContextMenuItem("Clear Helper", deleteButtons)
|
|
||||||
end
|
end
|
||||||
|
self.clearContextMenu()
|
||||||
|
self.addContextMenuItem("Clear Helper", toggleHelper)
|
||||||
|
end
|
||||||
|
syncDisplayWithOptionPanel()
|
||||||
end
|
end
|
||||||
|
|
||||||
function makeXMLButton()
|
function makeXMLButton()
|
||||||
@ -57,13 +69,42 @@ function makeXMLButton()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
updateSave()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create XML button to prompt choosing a sigil; acts as this card's helper
|
||||||
|
function initialize()
|
||||||
|
if sigil and sigil ~= nil then
|
||||||
|
makeXMLButton()
|
||||||
|
else
|
||||||
|
self.UI.setXmlTable({
|
||||||
|
{
|
||||||
|
tag = "Button",
|
||||||
|
attributes = {
|
||||||
|
height = 450,
|
||||||
|
width = 1400,
|
||||||
|
rotation = "0 0 180",
|
||||||
|
scale = "0.1 0.1 1",
|
||||||
|
position = "0 -55 -22",
|
||||||
|
padding = "50 50 50 50",
|
||||||
|
font = "font_teutonic-arkham",
|
||||||
|
fontSize = 300,
|
||||||
|
onClick = "chooseSigil",
|
||||||
|
color = "#77674DE6",
|
||||||
|
textColor = "White"
|
||||||
|
},
|
||||||
|
value = "Choose Sigil"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create dialog window to choose sigil and create sigil-drawing button
|
-- Create dialog window to choose sigil and create sigil-drawing button
|
||||||
function chooseSigil(playerColor)
|
function chooseSigil(player)
|
||||||
Player[playerColor].clearSelectedObjects()
|
player.clearSelectedObjects()
|
||||||
self.clearContextMenu()
|
self.clearContextMenu()
|
||||||
self.addContextMenuItem("Clear Helper", deleteButtons)
|
self.addContextMenuItem("Clear Helper", toggleHelper)
|
||||||
|
|
||||||
-- get list of readable names
|
-- get list of readable names
|
||||||
local readableNames = {}
|
local readableNames = {}
|
||||||
@ -72,21 +113,19 @@ function chooseSigil(playerColor)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- prompt player to choose sigil
|
-- prompt player to choose sigil
|
||||||
Player[playerColor].showOptionsDialog("Choose Sigil", readableNames, 1,
|
player.showOptionsDialog("Choose Sigil", readableNames, 1,
|
||||||
function(chosenToken)
|
function(chosenToken)
|
||||||
sigil = Global.call("getChaosTokenName", chosenToken)
|
sigil = Global.call("getChaosTokenName", chosenToken)
|
||||||
makeXMLButton()
|
makeXMLButton()
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
updateSave()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Delete button and remove sigil
|
function shutOff()
|
||||||
function deleteButtons(playerColor)
|
|
||||||
Player[playerColor].clearSelectedObjects()
|
|
||||||
self.clearContextMenu()
|
|
||||||
self.addContextMenuItem("Enable Helper", chooseSigil)
|
|
||||||
self.UI.setXml("")
|
self.UI.setXml("")
|
||||||
sigil = nil
|
sigil = nil
|
||||||
|
updateSave()
|
||||||
end
|
end
|
||||||
|
|
||||||
function resolveSigil()
|
function resolveSigil()
|
||||||
|
Loading…
Reference in New Issue
Block a user