diff --git a/objects/AllPlayerCards.15bb07/KhakuNarukami.54eaa7.json b/objects/AllPlayerCards.15bb07/KhakuNarukami.54eaa7.json index 7c317a95..e73ac888 100644 --- a/objects/AllPlayerCards.15bb07/KhakuNarukami.54eaa7.json +++ b/objects/AllPlayerCards.15bb07/KhakuNarukami.54eaa7.json @@ -33,7 +33,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "require(\"playercards/cards/KhakuNarukami\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", diff --git a/src/playercards/cards/KhakuNarukami.ttslua b/src/playercards/cards/KhakuNarukami.ttslua new file mode 100644 index 00000000..1c4acfde --- /dev/null +++ b/src/playercards/cards/KhakuNarukami.ttslua @@ -0,0 +1,64 @@ +function onSave() + return JSON.encode() +end + +function onLoad(savedData) + self.addContextMenuItem("Enable Helper", createButtons) + sigil = JSON.decode(savedData) + if sigil and sigil ~= nil then + makeXMLButton(sigil) + self.clearContextMenu() + self.addContextMenuItem("Clear Helper", deleteButtons) + end +end + +function makeXMLButton(chosenToken) + 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, + iconWidth=400, + iconAlignment="Right", + onClick="remove", + id=sigil, + icon=dataForToken[sigil].icon, + color=dataForToken[sigil].color, + textColor="White", + }, + value="Resolve", + } + } +) +end + +-- Create dialog window to choose sigil and create sigil-drawing button +function chooseSigil(playerColor) + self.clearContextMenu() + self.addContextMenuItem("Clear Helper", deleteButtons) + Player[playerColor].showOptionsDialog("Choose Sigil", tokenNames, 1, + function(chosenToken) + if chosenToken == "Custom Token" then + sigil = "" + else + sigil = chosenToken + end + makeXMLButton(sigil) + end + ) +end + +-- Delete button and remove sigil +function deleteButtons() + self.clearContextMenu() + self.addContextMenuItem("Enable Helper", chooseSigil) + self.UI.setXml("") + sigil = nil +end \ No newline at end of file