diff --git a/objects/AllPlayerCards.15bb07/Analysis.80285f.json b/objects/AllPlayerCards.15bb07/Analysis.80285f.json index dca8a054..f5050916 100644 --- a/objects/AllPlayerCards.15bb07/Analysis.80285f.json +++ b/objects/AllPlayerCards.15bb07/Analysis.80285f.json @@ -33,7 +33,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "require(\"playercards/cards/Analysis\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", diff --git a/objects/AllPlayerCards.15bb07/FamilyInheritance.394603.json b/objects/AllPlayerCards.15bb07/FamilyInheritance.394603.json index e9255f39..7810d8b5 100644 --- a/objects/AllPlayerCards.15bb07/FamilyInheritance.394603.json +++ b/objects/AllPlayerCards.15bb07/FamilyInheritance.394603.json @@ -58,5 +58,5 @@ "scaleZ": 1 }, "Value": 0, - "XmlUI": "" + "XmlUI": "\u003cInclude src=\"playercards/FamilyInheritance.xml\"/\u003e" } diff --git a/objects/AllPlayerCards.15bb07/Strong-Armed1.294d6.json b/objects/AllPlayerCards.15bb07/Strong-Armed1.294d6.json index 8903c9c5..244f2e0c 100644 --- a/objects/AllPlayerCards.15bb07/Strong-Armed1.294d6.json +++ b/objects/AllPlayerCards.15bb07/Strong-Armed1.294d6.json @@ -33,7 +33,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "require(\"playercards/cards/Strong-Armed\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", diff --git a/objects/AllPlayerCards.15bb07/ThirdTimesaCharm2.45956a.json b/objects/AllPlayerCards.15bb07/ThirdTimesaCharm2.45956a.json index fc9e9b96..ea0fc3c9 100644 --- a/objects/AllPlayerCards.15bb07/ThirdTimesaCharm2.45956a.json +++ b/objects/AllPlayerCards.15bb07/ThirdTimesaCharm2.45956a.json @@ -33,7 +33,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "require(\"playercards/cards/ThirdTimesaCharm\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", diff --git a/objects/LuaScriptState.luascriptstate b/objects/LuaScriptState.luascriptstate index 99a91195..62279893 100644 --- a/objects/LuaScriptState.luascriptstate +++ b/objects/LuaScriptState.luascriptstate @@ -1 +1 @@ -{"acknowledgedUpgradeVersions":[],"chaosTokensGUID":[],"optionPanel":{"cardLanguage":"en","changePlayAreaImage":false,"enableCardHelpers":false,"playAreaConnectionColor":{"a":1,"b":0.4,"g":0.4,"r":0.4},"playAreaConnections":true,"playAreaSnapTags":true,"showAttachmentHelper":false,"showCleanUpHelper":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":false,"showSearchAssistant":false,"showTitleSplash":true,"useClassTexture":true,"useClueClickers":false,"useResourceCounters":"disabled","useSnapTags":true}} +{"acknowledgedUpgradeVersions":[],"chaosTokensGUID":[],"optionPanel":{"cardLanguage":"en","changePlayAreaImage":false,"enableCardHelpers":true,"playAreaConnectionColor":{"a":1,"b":0.4,"g":0.4,"r":0.4},"playAreaConnections":true,"playAreaSnapTags":true,"showAttachmentHelper":false,"showCleanUpHelper":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":false,"showSearchAssistant":false,"showTitleSplash":true,"useClassTexture":true,"useClueClickers":false,"useResourceCounters":"disabled","useSnapTags":true}} diff --git a/src/accessories/SearchAssistant.ttslua b/src/accessories/SearchAssistant.ttslua index 3ecf8da7..316dffbe 100644 --- a/src/accessories/SearchAssistant.ttslua +++ b/src/accessories/SearchAssistant.ttslua @@ -4,6 +4,7 @@ local searchLib = require("util/SearchLib") -- forward declaration of variables that are used across functions local matColor, handColor, setAsidePosition, setAsideRotation, drawDeckPosition, topCardDetected +local addedVectorLines, addedSnapPoint local quickParameters = {} quickParameters.function_owner = self @@ -34,6 +35,7 @@ inputParameters.validation = 2 function onLoad() normalView() + self.max_typed_number = 9999 end -- regular view with search box @@ -89,6 +91,10 @@ function updateSearchNumber(_, _, input) inputParameters.value = tonumber(input) end +function onNumberTyped(playerColor, number) + startSearch(playerColor, number) +end + -- starts the search with the number from the input field function searchCustom(_, messageColor) local number = inputParameters.value @@ -115,7 +121,7 @@ function startSearch(messageColor, number) -- get bounds to know the height of the deck local bounds = deckAreaObjects.draw.getBounds() drawDeckPosition = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0) - printToColor("Place target(s) of search on set aside hand.", messageColor, "Green") + printToColor("Place target(s) of search on set aside spot.", messageColor, "Green") -- get playermat orientation local offset = -15 @@ -127,10 +133,28 @@ function startSearch(messageColor, number) local handData = Player[handColor].getHandTransform() local handCards = Player[handColor].getHandObjects() setAsidePosition = (handData.position + offset * handData.right):setAt("y", 1.5) - setAsideRotation = { handData.rotation.x, handData.rotation.y + 180, 180 } + setAsideRotation = Vector(handData.rotation.x, handData.rotation.y + 180, 180) -- place hand cards set aside - deckLib.placeOrMergeIntoDeck(handCards, setAsidePosition, setAsideRotation) + if #handCards > 0 then + deckLib.placeOrMergeIntoDeck(handCards, setAsidePosition, setAsideRotation) + end + + -- add a temporary snap point for the set aside spot + addedSnapPoint = { position = setAsidePosition, rotation = setAsideRotation } + local snapPoints = Global.getSnapPoints() or {} + table.insert(snapPoints, addedSnapPoint) + Global.setSnapPoints(snapPoints) + + -- add a temporary box for the set aside spot + local vectorLines = Global.getVectorLines() or {} + local boxSize = Vector(2.5, 0, 3.5) + addedVectorLines = generateBoxData(setAsidePosition, boxSize, setAsideRotation.y, handColor) + + for _, line in ipairs(addedVectorLines) do + table.insert(vectorLines, line) + end + Global.setVectorLines(vectorLines) -- handling for Norman Withers if deckAreaObjects.topCard then @@ -182,4 +206,77 @@ function drawSetAsideCards() end obj.deal(count, handColor) end + removeAddedSnapAndLines() +end + +function removeAddedSnapAndLines() + local vectorLines = Global.getVectorLines() or {} + local snapPoints = Global.getSnapPoints() or {} + + -- look for previously added data and remove it (iterate in reverse because we're removing entries) + for i = #vectorLines, 1, -1 do + for _, boxLine in ipairs(addedVectorLines) do + if vectorLines[i].points[1] == boxLine.points[1] and vectorLines[i].points[2] == boxLine.points[2] then + table.remove(vectorLines, i) + break + end + end + end + + for i = #snapPoints, 1, -1 do + if snapPoints[i].position == addedSnapPoint.position then + table.remove(snapPoints, i) + break + end + end + + Global.setVectorLines(vectorLines) + Global.setSnapPoints(snapPoints) +end + +-- generates the lines data for a rectangular box +---@param center tts__Vector Center of the box +---@param size tts__Vector X and Z dimension of the box +---@param rotation number Rotation around the Y-axis for the box +---@param boxColor string Color for the box +---@return table lines Vector line data for the box +function generateBoxData(center, size, rotation, boxColor) + local halfWidth = size.x / 2 + local halfDepth = size.z / 2 + + -- corners of the box in local coordinates + local corners = { + Vector(-halfWidth, 0, -halfDepth), + Vector(halfWidth, 0, -halfDepth), + Vector(halfWidth, 0, halfDepth), + Vector(-halfWidth, 0, halfDepth) + } + + -- translate corners to global coordinates + for i, cornerVec in ipairs(corners) do + local rotatedCornerVec = cornerVec:rotateOver('y', rotation) + corners[i] = rotatedCornerVec + center + end + + -- generate the lines data + local lines = { + { + points = { corners[1], corners[2] }, + color = boxColor + }, + { + points = { corners[2], corners[3] }, + color = boxColor + }, + { + points = { corners[3], corners[4] }, + color = boxColor + }, + { + points = { corners[4], corners[1] }, + color = boxColor + } + } + + return lines end diff --git a/src/chaosbag/ChaosBagApi.ttslua b/src/chaosbag/ChaosBagApi.ttslua index 218f63a9..4aa52eea 100644 --- a/src/chaosbag/ChaosBagApi.ttslua +++ b/src/chaosbag/ChaosBagApi.ttslua @@ -4,7 +4,7 @@ do -- respawns the chaos bag with a new state of tokens ---@param tokenList table List of chaos token ids ChaosBagApi.setChaosBagState = function(tokenList) - return Global.call("setChaosBagState", tokenList) + Global.call("setChaosBagState", tokenList) end -- returns a Table List of chaos token ids in the current chaos bag @@ -31,31 +31,31 @@ do -- returns all sealed tokens on cards to the chaos bag ---@param playerColor string Color of the player to show the broadcast to ChaosBagApi.releaseAllSealedTokens = function(playerColor) - return Global.call("releaseAllSealedTokens", playerColor) + Global.call("releaseAllSealedTokens", playerColor) end -- returns all drawn tokens to the chaos bag ChaosBagApi.returnChaosTokens = function() - return Global.call("returnChaosTokens") + Global.call("returnChaosTokens") end -- removes the specified chaos token from the chaos bag ---@param id string ID of the chaos token ChaosBagApi.removeChaosToken = function(id) - return Global.call("removeChaosToken", id) + Global.call("removeChaosToken", id) end -- returns a chaos token to the bag and calls all relevant functions ---@param token tts__Object Chaos token to return ---@param fromBag boolean whether or not the token to return was in the middle of being drawn (true) or elsewhere (false) ChaosBagApi.returnChaosTokenToBag = function(token, fromBag) - return Global.call("returnChaosTokenToBag", { token = token, fromBag = fromBag }) + Global.call("returnChaosTokenToBag", { token = token, fromBag = fromBag }) end -- spawns the specified chaos token and puts it into the chaos bag ---@param id string ID of the chaos token ChaosBagApi.spawnChaosToken = function(id) - return Global.call("spawnChaosToken", id) + Global.call("spawnChaosToken", id) end -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index b591245a..7aa4a621 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -452,6 +452,9 @@ function returnAndRedraw(_, tokenGUID) end redrawData = {} + + -- return a reference to the freshly drawn token + return chaosTokens[indexOfReturnedToken] end -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens @@ -1735,7 +1738,7 @@ function onClick_defaultSettings() optionPanel = { cardLanguage = "en", changePlayAreaImage = false, - enableCardHelpers = false, + enableCardHelpers = true, playAreaConnectionColor = { a = 1, b = 0.4, g = 0.4, r = 0.4 }, playAreaConnections = true, playAreaSnapTags = true, diff --git a/src/playercards/CardsThatRedrawTokens.ttslua b/src/playercards/CardsThatRedrawTokens.ttslua index b975f8a2..5f7c8813 100644 --- a/src/playercards/CardsThatRedrawTokens.ttslua +++ b/src/playercards/CardsThatRedrawTokens.ttslua @@ -51,20 +51,21 @@ As a nice reminder the XML button takes on the Frost color and icon with the tex > require... ----------------------------------------------------------]] -local isHelperEnabled = false +-- intentionally global +hasXML = true +isHelperEnabled = false function updateSave() self.script_state = JSON.encode({ isHelperEnabled = isHelperEnabled }) end function onLoad(savedData) - self.addTag("CardWithHelper") if savedData and savedData ~= "" then local loadedData = JSON.decode(savedData) isHelperEnabled = loadedData.isHelperEnabled end createHelperXML() - checkOptionPanel() + syncDisplayWithOptionPanel() end function createHelperXML() @@ -95,14 +96,6 @@ function createHelperXML() self.UI.setXmlTable(xmlTable) end -function shutOff() - self.UI.hide("Helper") -end - -function initialize() - self.UI.show("Helper") -end - function triggerXMLTokenLabelCreation() Global.call("activeRedrawEffect", { VALID_TOKENS = VALID_TOKENS, diff --git a/src/playercards/CardsWithHelper.ttslua b/src/playercards/CardsWithHelper.ttslua index c92ffda9..dc67ee1b 100644 --- a/src/playercards/CardsWithHelper.ttslua +++ b/src/playercards/CardsWithHelper.ttslua @@ -1,7 +1,23 @@ +--[[ Library for cards that have helpers +This file is used to share code between cards with helpers. +It syncs the visibility of the helper with the option panel and +makes sure the card has the respective tag. +Additionally, it will call 'initiliaze()' and 'shutOff()' +in the parent file if they are present. + +Instructions: +1) Define the global variables before requiring this file: +hasXML = true (whether the card has an XML display) +isHelperEnabled = false (default state of the helper, should be 'false') + +2) In 'onLoad()'', call 'syncDisplayWithOptionPanel()' +----------------------------------------------------------]] + local optionPanelApi = require("core/OptionPanelApi") -- if the respective option is enabled in onLoad(), enable the helper -function checkOptionPanel() +function syncDisplayWithOptionPanel() + self.addTag("CardWithHelper") local options = optionPanelApi.getOptions() if options.enableCardHelpers then setHelperState(true) @@ -33,10 +49,12 @@ function actualDisplayUpdate() if isHelperEnabled then self.clearContextMenu() self.addContextMenuItem("Disable Helper", toggleHelper) + if hasXML then self.UI.show("Helper") end if initialize then initialize() end else self.clearContextMenu() self.addContextMenuItem("Enable Helper", toggleHelper) + if hasXML then self.UI.hide("Helper") end if shutOff then shutOff() end end end diff --git a/src/playercards/cards/Analysis.ttslua b/src/playercards/cards/Analysis.ttslua new file mode 100644 index 00000000..f183bf63 --- /dev/null +++ b/src/playercards/cards/Analysis.ttslua @@ -0,0 +1,2 @@ +require("playercards/CardsWithHelper") +require("playercards/CardsThatRedrawTokens") diff --git a/src/playercards/cards/BookofLivingMyths.ttslua b/src/playercards/cards/BookofLivingMyths.ttslua index 776c9d8b..b4d564d0 100644 --- a/src/playercards/cards/BookofLivingMyths.ttslua +++ b/src/playercards/cards/BookofLivingMyths.ttslua @@ -1,38 +1,40 @@ require("playercards/CardsWithHelper") -local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") -local chaosBagApi = require("chaosbag/ChaosBagApi") -local guidReferenceApi = require("core/GUIDReferenceApi") -local playermatApi = require("playermat/PlayermatApi") +local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") +local chaosBagApi = require("chaosbag/ChaosBagApi") +local guidReferenceApi = require("core/GUIDReferenceApi") +local playermatApi = require("playermat/PlayermatApi") -local isHelperEnabled = false -local updated +-- intentionally global +hasXML = true +isHelperEnabled = false +local updated, loopId function updateSave() - self.script_state = JSON.encode({ isHelperEnabled = isHelperEnabled }) + self.script_state = JSON.encode({ + isHelperEnabled = isHelperEnabled, + loopId = loopId + }) end function onLoad(savedData) - self.addTag("CardWithHelper") if savedData and savedData ~= "" then local loadedData = JSON.decode(savedData) isHelperEnabled = loadedData.isHelperEnabled + loopId = loadedData.loopId end - checkOptionPanel() + syncDisplayWithOptionPanel() end --- hide buttons and stop monitoring function shutOff() - self.UI.hide("Helper") - Wait.stopAll() - updateSave() + if loopId then + Wait.stop(loopId) + loopId = nil + end end --- show buttons and begin monitoring chaos bag for curse and bless tokens function initialize() - self.UI.show("Helper") maybeUpdateButtonState() - Wait.time(maybeUpdateButtonState, 1, -1) - updateSave() + loopId = Wait.time(maybeUpdateButtonState, 1, -1) end function resolveToken(player, _, tokenType) diff --git a/src/playercards/cards/EmpiricalHypothesis.ttslua b/src/playercards/cards/EmpiricalHypothesis.ttslua index d2b410d3..2a68a3bd 100644 --- a/src/playercards/cards/EmpiricalHypothesis.ttslua +++ b/src/playercards/cards/EmpiricalHypothesis.ttslua @@ -1,5 +1,9 @@ require("playercards/CardsWithHelper") -local playermatApi = require("playermat/PlayermatApi") +local playermatApi = require("playermat/PlayermatApi") + +-- intentionally global +hasXML = false +isHelperEnabled = false -- common button parameters local buttonParameters = {} @@ -28,7 +32,6 @@ local customizableList = { -- index of the currently selected button (0-indexed from the top) local activeButtonIndex = -1 -local isHelperEnabled = false local hypothesisList = {} function updateSave() @@ -39,17 +42,17 @@ function updateSave() end function onLoad(savedData) - self.addTag("CardWithHelper") if savedData and savedData ~= "" then local loadedData = JSON.decode(savedData) isHelperEnabled = loadedData.isHelperEnabled activeButtonIndex = loadedData.activeButtonIndex end - checkOptionPanel() if activeButtonIndex > 0 then selectButton(activeButtonIndex) end + + syncDisplayWithOptionPanel() end function initialize() @@ -74,7 +77,7 @@ function selectButton(index) end end --- Create buttons based on the button parameters +-- create buttons based on the button parameters function createButtons() self.clearButtons() @@ -88,7 +91,6 @@ function createButtons() local upgradeSheet = findUpgradeSheet() if upgradeSheet then for i = 1, 4 do - log(4) if upgradeSheet.call("isUpgradeActive", i) then table.insert(hypothesisList, customizableList[i]) end diff --git a/src/playercards/cards/FamilyInheritance.ttslua b/src/playercards/cards/FamilyInheritance.ttslua index e5b71240..e30f944b 100644 --- a/src/playercards/cards/FamilyInheritance.ttslua +++ b/src/playercards/cards/FamilyInheritance.ttslua @@ -1,26 +1,24 @@ -local playermatApi = require("playermat/PlayermatApi") -local searchLib = require("util/SearchLib") -local tokenManager = require("core/token/TokenManager") +require("playercards/CardsWithHelper") +local playermatApi = require("playermat/PlayermatApi") +local searchLib = require("util/SearchLib") +local tokenManager = require("core/token/TokenManager") +-- intentionally global +hasXML = true +isHelperEnabled = false local clickableResourceCounter = nil -local foundTokens = 0 +local foundTokens = 0 -function onLoad() - self.addContextMenuItem("Add 4 resources", - function(playerColor) - Player[playerColor].clearSelectedObjects() - add4(playerColor) - end) - self.addContextMenuItem("Take all resources", - function(playerColor) - Player[playerColor].clearSelectedObjects() - takeAll(playerColor) - end) - self.addContextMenuItem("Discard all resources", - function(playerColor) - Player[playerColor].clearSelectedObjects() - loseAll(playerColor) - end) +function updateSave() + self.script_state = JSON.encode({ isHelperEnabled = isHelperEnabled }) +end + +function onLoad(savedData) + if savedData and savedData ~= "" then + local loadedData = JSON.decode(savedData) + isHelperEnabled = loadedData.isHelperEnabled + end + syncDisplayWithOptionPanel() end function searchSelf() @@ -40,7 +38,7 @@ function searchSelf() end end -function add4(playerColor) +function add4() searchSelf() local newCount = foundTokens + 4 @@ -51,7 +49,7 @@ function add4(playerColor) end end -function takeAll(playerColor) +function takeAll(player) searchSelf() local matColor = playermatApi.getMatColorByPosition(self.getPosition()) playermatApi.updateCounter(matColor, "ResourceCounter", _, foundTokens) @@ -59,14 +57,13 @@ function takeAll(playerColor) if clickableResourceCounter then clickableResourceCounter.call("updateVal", 0) end - printToColor("Moved " .. foundTokens .. " resource(s) to " .. matColor .. "'s resource pool.", playerColor) + printToColor("Moved " .. foundTokens .. " resource(s) to " .. matColor .. "'s resource pool.", player.color) end -function loseAll(playerColor) +function loseAll(player) searchSelf() - if clickableResourceCounter then clickableResourceCounter.call("updateVal", 0) end - printToColor("Discarded " .. foundTokens .. " resource(s).", playerColor) + printToColor("Discarded " .. foundTokens .. " resource(s).", player.color) end diff --git a/src/playercards/cards/KohakuNarukami.ttslua b/src/playercards/cards/KohakuNarukami.ttslua index 5d478997..d033135f 100644 --- a/src/playercards/cards/KohakuNarukami.ttslua +++ b/src/playercards/cards/KohakuNarukami.ttslua @@ -5,8 +5,10 @@ local playermatApi = require("playermat/PlayermatApi") local searchLib = require("util/SearchLib") local tokenManager = require("core/token/TokenManager") -local isHelperEnabled = false -local updated +-- intentionally global +hasXML = true +isHelperEnabled = false +local updated, loopId local xmlData = { Action = { color = "#6D202CE6", onClick = "removeAndExtraAction" }, @@ -16,31 +18,31 @@ local xmlData = { } function updateSave() - self.script_state = JSON.encode({ isHelperEnabled = isHelperEnabled }) + self.script_state = JSON.encode({ + isHelperEnabled = isHelperEnabled, + loopId = loopId + }) end function onLoad(savedData) - self.addTag("CardWithHelper") if savedData and savedData ~= "" then local loadedData = JSON.decode(savedData) isHelperEnabled = loadedData.isHelperEnabled + loopId = loadedData.loopId end - checkOptionPanel() + syncDisplayWithOptionPanel() end --- hide buttons and stop monitoring -function shutOff() - self.UI.hide("Helper") - Wait.stopAll() - updateSave() -end - --- show buttons and begin monitoring chaos bag for curse and bless tokens function initialize() - self.UI.show("Helper") maybeUpdateButtonState() - Wait.time(maybeUpdateButtonState, 1, -1) - updateSave() + loopId = Wait.time(maybeUpdateButtonState, 1, -1) +end + +function shutOff() + if loopId then + Wait.stop(loopId) + loopId = nil + end end function addTokenToBag(_, _, tokenType) diff --git a/src/playercards/cards/Strong-Armed.ttslua b/src/playercards/cards/Strong-Armed.ttslua new file mode 100644 index 00000000..f183bf63 --- /dev/null +++ b/src/playercards/cards/Strong-Armed.ttslua @@ -0,0 +1,2 @@ +require("playercards/CardsWithHelper") +require("playercards/CardsThatRedrawTokens") diff --git a/src/playercards/cards/ThirdTimesaCharm.ttslua b/src/playercards/cards/ThirdTimesaCharm.ttslua new file mode 100644 index 00000000..f183bf63 --- /dev/null +++ b/src/playercards/cards/ThirdTimesaCharm.ttslua @@ -0,0 +1,2 @@ +require("playercards/CardsWithHelper") +require("playercards/CardsThatRedrawTokens") diff --git a/src/playercards/cards/WellConnected.ttslua b/src/playercards/cards/WellConnected.ttslua index c90ca5e4..8f8653f2 100644 --- a/src/playercards/cards/WellConnected.ttslua +++ b/src/playercards/cards/WellConnected.ttslua @@ -1,5 +1,11 @@ require("playercards/CardsWithHelper") -local playermatApi = require("playermat/PlayermatApi") +local playermatApi = require("playermat/PlayermatApi") + +-- intentionally global +hasXML = false +isHelperEnabled = false + +local modValue, loopId local buttonParameters = { click_function = "shutOff", @@ -10,13 +16,20 @@ local buttonParameters = { height = 175 } -local modValue - function updateSave() - self.script_state = JSON.encode({ isHelperEnabled = isHelperEnabled }) + self.script_state = JSON.encode({ + isHelperEnabled = isHelperEnabled, + loopId = loopId + }) end function onLoad(savedData) + if savedData and savedData ~= "" then + local loadedData = JSON.decode(savedData) + isHelperEnabled = loadedData.isHelperEnabled + loopId = loadedData.loopId + end + -- use metadata to detect level and adjust modValue accordingly if JSON.decode(self.getGMNotes()).level == 0 then modValue = 5 @@ -24,25 +37,22 @@ function onLoad(savedData) modValue = 4 end - self.addTag("CardWithHelper") - if savedData and savedData ~= "" then - local loadedData = JSON.decode(savedData) - isHelperEnabled = loadedData.isHelperEnabled - end - checkOptionPanel() - updateDisplay() + syncDisplayWithOptionPanel() end function initialize() self.clearButtons() self.createButton(buttonParameters) updateButton() - Wait.time(updateButton, 2, -1) + loopId = Wait.time(updateButton, 2, -1) end function shutOff() self.clearButtons() - Wait.stopAll() + if loopId then + Wait.stop(loopId) + loopId = nil + end end function updateButton() diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index fea8196e..a58aeeb8 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -63,12 +63,12 @@ local buttonParameters = { -- table of texture URLs local nameToTexture = { - Guardian = "http://cloud-3.steamusercontent.com/ugc/2501268517203536128/853B9CD08FC14A8B2A08C73D8ED77E0FE235CCCB/", - Mystic = "http://cloud-3.steamusercontent.com/ugc/2501268517203536470/11C99488B9CA9236059A5F02E4A852A7C77B42A6/", + Guardian = "http://cloud-3.steamusercontent.com/ugc/2501268517241599869/179119CA88170D9F5C87CD00D267E6F9F397D2F7/", + Mystic = "http://cloud-3.steamusercontent.com/ugc/2501268517241600113/F6473F92B3435C32A685BB4DC2A88C2504DDAC4F/", Neutral = "http://cloud-3.steamusercontent.com/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", - Rogue = "http://cloud-3.steamusercontent.com/ugc/2501268517203536767/587791B327255DB8F953B27BB9E4DE602FA32B64/", - Seeker = "http://cloud-3.steamusercontent.com/ugc/2501268517203537098/EFD9FC4CCDB105EFFDFF7A57C915CD984865760D/", - Survivor = "http://cloud-3.steamusercontent.com/ugc/2501268517203537426/14EF780606D9A449F31A007226CB48D05AA820FF/" + Rogue = "http://cloud-3.steamusercontent.com/ugc/2501268517241600395/00CFAFC13D7B6EACC147D22A40AF9FBBFFAF3136/", + Seeker = "http://cloud-3.steamusercontent.com/ugc/2501268517241600579/92DEB412D8D3A9C26D1795CEA0335480409C3E4B/", + Survivor = "http://cloud-3.steamusercontent.com/ugc/2501268517241600848/CEB685E9C8A4A3C18A4B677A519B49423B54E886/" } -- translation table for slot names to characters for special font diff --git a/xml/playercards/FamilyInheritance.xml b/xml/playercards/FamilyInheritance.xml new file mode 100644 index 00000000..31723647 --- /dev/null +++ b/xml/playercards/FamilyInheritance.xml @@ -0,0 +1,37 @@ + +