Changed save functions
This commit is contained in:
parent
d898676b6a
commit
a795423813
@ -1,17 +1,18 @@
|
||||
tableHeightOffset = -9
|
||||
|
||||
function onSave()
|
||||
return JSON.encode({ tid = tableImageData, cd = checkData })
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode({ tid = tableImageData, cd = checkData })
|
||||
end
|
||||
|
||||
function onload(saved_data)
|
||||
if saved_data ~= "" then
|
||||
local loaded_data = JSON.decode(saved_data)
|
||||
function onload(savedData)
|
||||
if savedData and savedData ~= "" then
|
||||
local loaded_data = JSON.decode(savedData)
|
||||
tableImageData = loaded_data.tid
|
||||
checkData = loaded_data.cd
|
||||
else
|
||||
tableImageData = {}
|
||||
checkData = { move = false, scale = false }
|
||||
updateSave()
|
||||
end
|
||||
|
||||
--Disables interactable status of objects with GUID in list
|
||||
@ -83,6 +84,7 @@ function click_saveSurface(_, color)
|
||||
if findInImageDataIndex(url, nickname) == nil then
|
||||
--Save doesn't exist already
|
||||
table.insert(tableImageData, { url = url, name = nickname })
|
||||
updateSave()
|
||||
broadcastToAll("Image URL saved to memory.", { 0.2, 0.9, 0.2 })
|
||||
--Refresh buttons
|
||||
self.clearButtons()
|
||||
@ -111,6 +113,7 @@ end
|
||||
function click_deleteMemory(_, color, index)
|
||||
if permissionCheck(color) then
|
||||
table.remove(tableImageData, index)
|
||||
updateSave()
|
||||
self.clearButtons()
|
||||
createOpenCloseButton()
|
||||
createSurfaceButtons()
|
||||
@ -166,28 +169,10 @@ function click_checkMove(_, color)
|
||||
local buttonEntry = findButton(self, find_func)
|
||||
self.editButton({ index = buttonEntry.index, label = string.char(10008) })
|
||||
end
|
||||
updateSave()
|
||||
end
|
||||
end
|
||||
|
||||
--Checks/unchecks scale box for hands
|
||||
--This button was disabled for technical reasons
|
||||
--[[
|
||||
function click_checkScale(_, color)
|
||||
if permissionCheck(color) then
|
||||
local find_func = function(o) return o.click_function=="click_checkScale" end
|
||||
if checkData.scale == true then
|
||||
checkData.scale = false
|
||||
local buttonEntry = findButton(self, find_func)
|
||||
self.editButton({index=buttonEntry.index, label=""})
|
||||
else
|
||||
checkData.scale = true
|
||||
local buttonEntry = findButton(self, find_func)
|
||||
self.editButton({index=buttonEntry.index, label=string.char(10008)})
|
||||
end
|
||||
end
|
||||
end
|
||||
]]
|
||||
|
||||
--Alters scale of elements and moves them
|
||||
function changeTableScale(width, depth)
|
||||
--Scaling factors used to translate scale to position offset
|
||||
@ -506,13 +491,6 @@ function createScaleButtons()
|
||||
font_size = 200,
|
||||
font_color = { 1, 1, 1 }
|
||||
})
|
||||
--Disabled due to me removing the feature for technical reasons
|
||||
--[[
|
||||
self.createButton({
|
||||
label="Scale Hands:", click_function="none",
|
||||
position={-8.3,0,4}, height=0, width=0, font_size=200, font_color={1,1,1}
|
||||
})
|
||||
]]
|
||||
--Checkboxes
|
||||
local label = ""
|
||||
if checkData.move == true then label = string.char(10008) end
|
||||
@ -526,15 +504,6 @@ function createScaleButtons()
|
||||
width = 224,
|
||||
font_size = 200,
|
||||
})
|
||||
--[[
|
||||
local label = ""
|
||||
if checkData.scale == true then label = string.char(10008) end
|
||||
self.createButton({
|
||||
label=label, click_function="click_checkScale",
|
||||
function_owner=self, tooltip="Check to scale the width of hands when table is rescaled",
|
||||
position={-6.8,0,4}, height=224, width=224, font_size=200,
|
||||
})
|
||||
]]
|
||||
--Apply button
|
||||
self.createButton({
|
||||
label = "Apply Scale",
|
||||
|
@ -4,8 +4,8 @@ local MIN_VALUE = -10
|
||||
local MAX_VALUE = 99
|
||||
local vp, notes
|
||||
|
||||
function onSave()
|
||||
return JSON.encode({ vp = vp, notes = notes })
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode({ vp = vp, notes = notes })
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
@ -16,6 +16,7 @@ function onLoad(savedData)
|
||||
else
|
||||
vp = 1
|
||||
notes = "Click to type"
|
||||
updateSave()
|
||||
end
|
||||
|
||||
createButtons()
|
||||
@ -52,17 +53,13 @@ function createTextbox()
|
||||
})
|
||||
end
|
||||
|
||||
function updateNotes()
|
||||
function updateMetadata()
|
||||
local md = JSON.decode(self.getGMNotes())
|
||||
md.victory = vp
|
||||
self.setGMNotes(JSON.encode(md))
|
||||
victoryDisplayApi.update()
|
||||
end
|
||||
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode({ vp = vp, notes = notes })
|
||||
end
|
||||
|
||||
function input_function(_, _, inputValue, selected)
|
||||
if selected == false then
|
||||
notes = inputValue
|
||||
@ -74,5 +71,5 @@ function click_function(_, _, isRightClick)
|
||||
vp = math.min(math.max(vp + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)
|
||||
self.editButton({ index = 0, label = tostring(vp) })
|
||||
updateSave()
|
||||
updateNotes()
|
||||
updateMetadata()
|
||||
end
|
||||
|
@ -63,12 +63,13 @@ function loadData(loadedData)
|
||||
includeDrawnTokens = loadedData.includeDrawnTokens
|
||||
|
||||
updateUI()
|
||||
updateSave()
|
||||
Wait.time(layout, 1.5)
|
||||
end
|
||||
|
||||
-- saving the precedence settings and information on the most recently loaded data
|
||||
function onSave()
|
||||
return JSON.encode(getSaveData())
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode(getSaveData())
|
||||
end
|
||||
|
||||
-- loading data, button creation and initial layouting
|
||||
@ -104,6 +105,7 @@ function onLoad(savedData)
|
||||
includeDrawnTokens = not includeDrawnTokens
|
||||
local text = includeDrawnTokens and " " or " not "
|
||||
broadcastToAll("Token Arranger will" .. text .. "include currently drawn chaos tokens.", "Orange")
|
||||
updateSave()
|
||||
layout()
|
||||
end)
|
||||
|
||||
@ -114,6 +116,7 @@ function onLoad(savedData)
|
||||
percentage = "basic"
|
||||
broadcastToAll("Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).", "Yellow")
|
||||
end
|
||||
updateSave()
|
||||
layout()
|
||||
end)
|
||||
|
||||
@ -124,6 +127,7 @@ function onLoad(savedData)
|
||||
percentage = "cumulative"
|
||||
end
|
||||
broadcastToAll("Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).", "Yellow")
|
||||
updateSave()
|
||||
layout()
|
||||
end)
|
||||
end
|
||||
@ -145,6 +149,7 @@ function tokenClick(isRightClick, index)
|
||||
index = index - 1,
|
||||
value = tokenPrecedence[TOKEN_NAMES[index]][1]
|
||||
})
|
||||
updateSave()
|
||||
layout()
|
||||
end
|
||||
|
||||
@ -154,8 +159,9 @@ function tokenInput(input, selected, index)
|
||||
local num = tonumber(input)
|
||||
if num ~= nil then
|
||||
tokenPrecedence[TOKEN_NAMES[index]][1] = num
|
||||
updateSave()
|
||||
layout()
|
||||
end
|
||||
layout()
|
||||
end
|
||||
end
|
||||
|
||||
@ -175,6 +181,7 @@ function loadDefaultValues()
|
||||
["Frost"] = { -105, 10},
|
||||
[""] = { 0, 11}
|
||||
}
|
||||
updateSave()
|
||||
end
|
||||
|
||||
-- creates buttons and inputs
|
||||
@ -422,5 +429,6 @@ function onTokenDataChanged(parameters)
|
||||
end
|
||||
|
||||
updateUI()
|
||||
updateSave()
|
||||
layout()
|
||||
end
|
||||
|
@ -85,38 +85,6 @@ modeData = {
|
||||
}
|
||||
}
|
||||
|
||||
function onSave()
|
||||
return JSON.encode(SPAWNED_PLAYER_CARD_GUIDS)
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
if savedData and savedData ~= '' then
|
||||
SPAWNED_PLAYER_CARD_GUIDS = JSON.decode(savedData)
|
||||
else
|
||||
SPAWNED_PLAYER_CARD_GUIDS = {}
|
||||
end
|
||||
end
|
||||
|
||||
function getSpawnedPlayerCardGuid(params)
|
||||
local guid = params[1]
|
||||
if SPAWNED_PLAYER_CARD_GUIDS == nil then
|
||||
return nil
|
||||
else
|
||||
return SPAWNED_PLAYER_CARD_GUIDS[guid]
|
||||
end
|
||||
end
|
||||
|
||||
function setSpawnedPlayerCardGuid(params)
|
||||
local guid = params[1]
|
||||
local value = params[2]
|
||||
if SPAWNED_PLAYER_CARD_GUIDS ~= nil then
|
||||
SPAWNED_PLAYER_CARD_GUIDS[guid] = value
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- called by "Global" during encounter card drawing
|
||||
function checkHiddenCard(name)
|
||||
for _, n in ipairs(HIDDEN_CARD_DATA) do
|
||||
|
@ -104,7 +104,9 @@ local editsToIndex = {
|
||||
}
|
||||
|
||||
-- save function to keep edits to the index
|
||||
function onSave() return JSON.encode({ editsToIndex = editsToIndex }) end
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode({ editsToIndex = editsToIndex })
|
||||
end
|
||||
|
||||
-- load function to restore edits to the index
|
||||
function onLoad(savedData)
|
||||
@ -158,6 +160,7 @@ end
|
||||
-- makes an edit to the main index
|
||||
function editIndex(params)
|
||||
editsToIndex[params.owner][params.type] = params.guid
|
||||
updateSave()
|
||||
updateMainIndex()
|
||||
end
|
||||
|
||||
|
@ -1773,7 +1773,7 @@ function applyOptionPanelChange(id, state)
|
||||
|
||||
-- update master clue counter
|
||||
local counter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "MasterClueCounter")
|
||||
counter.setVar("useClickableCounters", state)
|
||||
counter.call("setClickableCounters", state)
|
||||
|
||||
-- option: Enable card helpers
|
||||
elseif id == "enableCardHelpers" then
|
||||
|
@ -2,9 +2,12 @@ local playermatApi = require("playermat/PlayermatApi")
|
||||
|
||||
-- variables are intentionally global to be accessible
|
||||
count = 0
|
||||
useClickableCounters = false
|
||||
|
||||
function onSave() return JSON.encode(useClickableCounters) end
|
||||
local useClickableCounters = false
|
||||
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode(useClickableCounters)
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
if savedData and savedData ~= "" then
|
||||
@ -28,6 +31,11 @@ function onLoad(savedData)
|
||||
Wait.time(sumClues, 2, -1)
|
||||
end
|
||||
|
||||
function setClickableCounters(state)
|
||||
useClickableCounters = state
|
||||
updateSave()
|
||||
end
|
||||
|
||||
-- removes all player clues by calling the respective function from the counting bowls / clickers
|
||||
function removeAllPlayerClues()
|
||||
printToAll(count .. " clue(s) from playermats removed.", "White")
|
||||
|
@ -249,7 +249,7 @@ end
|
||||
|
||||
-- handles all button clicks
|
||||
function buttonClicked(player, _, id)
|
||||
local index = tonumber(id) or ""
|
||||
local index = tonumber(id)
|
||||
|
||||
if index == 19 then
|
||||
setVisibility("toggle", player.color)
|
||||
|
@ -50,8 +50,8 @@ local currentScenario, connectionsEnabled
|
||||
-- general code
|
||||
---------------------------------------------------------
|
||||
|
||||
function onSave()
|
||||
return JSON.encode({
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode({
|
||||
trackedLocations = locations,
|
||||
currentScenario = currentScenario,
|
||||
connectionColor = connectionColor,
|
||||
@ -165,9 +165,11 @@ function onUpdate()
|
||||
-- Even if the last location left the play area, need one last draw to clear the lines
|
||||
needsConnectionDraw = true
|
||||
end
|
||||
|
||||
if needsConnectionRebuild then
|
||||
rebuildConnectionList()
|
||||
end
|
||||
|
||||
if needsConnectionDraw then
|
||||
drawDraggingConnections()
|
||||
end
|
||||
@ -222,6 +224,7 @@ function maybeTrackLocation(card)
|
||||
else
|
||||
locations[card.getGUID()] = metadata.locationFront
|
||||
end
|
||||
updateSave()
|
||||
|
||||
-- only draw connection lines for not-excluded scenarios
|
||||
if showLocationLinks() then
|
||||
@ -243,6 +246,7 @@ function maybeUntrackLocation(card)
|
||||
-- area. If the object is now locked, don't remove it.
|
||||
if locations[card.getGUID()] ~= nil and not card.locked then
|
||||
locations[card.getGUID()] = nil
|
||||
updateSave()
|
||||
rebuildConnectionList()
|
||||
drawBaseConnections()
|
||||
end
|
||||
@ -632,7 +636,7 @@ function updateSurface(newURL)
|
||||
guid = customDataHelper.getGUID()
|
||||
end
|
||||
|
||||
self.script_state = onSave()
|
||||
updateSave()
|
||||
self.reload()
|
||||
|
||||
if guid ~= nil then
|
||||
@ -664,6 +668,7 @@ function setConnectionDrawState(state)
|
||||
connectionsEnabled = state
|
||||
rebuildConnectionList()
|
||||
drawBaseConnections()
|
||||
updateSave()
|
||||
end
|
||||
|
||||
-- called by the option panel to edit the location connection color
|
||||
@ -671,6 +676,7 @@ function setConnectionColor(color)
|
||||
connectionColor = color
|
||||
rebuildConnectionList()
|
||||
drawBaseConnections()
|
||||
updateSave()
|
||||
end
|
||||
|
||||
function onScenarioChanged(scenarioName)
|
||||
@ -678,6 +684,7 @@ function onScenarioChanged(scenarioName)
|
||||
if not showLocationLinks() then
|
||||
broadcastToAll("Automatic location connections not available for this scenario")
|
||||
end
|
||||
updateSave()
|
||||
end
|
||||
|
||||
function getTrackedLocations()
|
||||
|
@ -3,8 +3,8 @@ local GlobalApi = require("core/GlobalApi")
|
||||
local playAreaApi = require("core/PlayAreaApi")
|
||||
local typeIndex, selectionIndex, plainNameCache
|
||||
|
||||
function onSave()
|
||||
return JSON.encode({
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode({
|
||||
typeIndex = typeIndex,
|
||||
selectionIndex = selectionIndex
|
||||
})
|
||||
@ -103,11 +103,13 @@ end
|
||||
function onClick_imageTab(_, _, tabId)
|
||||
typeIndex = tonumber(tabId:sub(9))
|
||||
selectionIndex = 1
|
||||
updateSave()
|
||||
updatePlayAreaGallery()
|
||||
end
|
||||
|
||||
function onClick_listItem(_, _, listId)
|
||||
selectionIndex = tonumber(listId:sub(10))
|
||||
updateSave()
|
||||
updatePlayAreaGallery()
|
||||
end
|
||||
|
||||
|
@ -54,8 +54,8 @@ local colorsForClasses = {
|
||||
|
||||
local highlightColor = { 0, 0.7843, 0.7843 }
|
||||
|
||||
function onSave()
|
||||
return JSON.encode({ class = class, symbol = symbol })
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode({ class = class, symbol = symbol })
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
@ -258,6 +258,7 @@ function updateClass(newClass)
|
||||
symbol = newClass or "Neutral"
|
||||
end
|
||||
class = newClass or "Neutral"
|
||||
updateSave()
|
||||
updateDisplay()
|
||||
end
|
||||
|
||||
@ -267,6 +268,7 @@ function updateSymbol(newSymbol)
|
||||
if symbol == "Universal" then
|
||||
symbol = class
|
||||
end
|
||||
updateSave()
|
||||
updateDisplay()
|
||||
end
|
||||
|
||||
@ -277,6 +279,7 @@ function updateClassAndSymbol(params)
|
||||
if symbol == "Universal" then
|
||||
symbol = class
|
||||
end
|
||||
updateSave()
|
||||
updateDisplay()
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
local spawnedCardGuids = {}
|
||||
|
||||
function onSave() return JSON.encode({ cards = spawnedCardGuids }) end
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode({ cards = spawnedCardGuids })
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
if savedData and savedData ~= "" then
|
||||
@ -20,13 +22,18 @@ end
|
||||
|
||||
function markTokensSpawned(cardGuid)
|
||||
spawnedCardGuids[cardGuid] = true
|
||||
updateSave()
|
||||
end
|
||||
|
||||
function resetTokensSpawned(card)
|
||||
spawnedCardGuids[card.getGUID()] = nil
|
||||
updateSave()
|
||||
end
|
||||
|
||||
function resetAll() spawnedCardGuids = {} end
|
||||
function resetAll()
|
||||
spawnedCardGuids = {}
|
||||
updateSave()
|
||||
end
|
||||
|
||||
function resetAllLocations() resetSpecificTypes("Location") end
|
||||
|
||||
@ -46,6 +53,7 @@ function resetSpecificTypes(type1, type2)
|
||||
end
|
||||
for cardGuid, _ in pairs(resetList) do
|
||||
spawnedCardGuids[cardGuid] = nil
|
||||
updateSave()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -23,8 +23,8 @@ inputParameters.scale = { 0.12, 1, 0.12 }
|
||||
inputParameters.color = { 0.9, 0.7, 0.5 }
|
||||
inputParameters.font_color = { 0, 0, 0 }
|
||||
|
||||
function onSave()
|
||||
return JSON.encode({ spawnAll, searchExact, inputParameters.value })
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode({ spawnAll, searchExact, inputParameters.value })
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
@ -68,11 +68,13 @@ end
|
||||
function toggleSpawnMode()
|
||||
spawnAll = not spawnAll
|
||||
self.editButton({ index = 0, label = BUTTON_LABELS["spawn"][spawnAll] })
|
||||
updateSave()
|
||||
end
|
||||
|
||||
function toggleSearchMode()
|
||||
searchExact = not searchExact
|
||||
self.editButton({ index = 1, label = BUTTON_LABELS["search"][searchExact] })
|
||||
updateSave()
|
||||
end
|
||||
|
||||
-- if "Enter press" (\n) is found, start search and recreate input
|
||||
@ -84,6 +86,7 @@ function input_func(_, _, input, stillEditing)
|
||||
startSearch()
|
||||
self.removeInput(0)
|
||||
self.createInput(inputParameters)
|
||||
updateSave()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -7,7 +7,9 @@ buttonParameters.color = { 0, 0, 0, 0 }
|
||||
buttonParameters.font_color = { 0, 0, 0, 100 }
|
||||
buttonParameters.font_size = 450
|
||||
|
||||
function onSave() return JSON.encode(stats) end
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode(stats)
|
||||
end
|
||||
|
||||
-- load stats and make buttons (left to right)
|
||||
function onLoad(savedData)
|
||||
@ -29,6 +31,7 @@ end
|
||||
|
||||
function buttonClick(isRightClick, index)
|
||||
stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99)
|
||||
updateSave()
|
||||
updateButtonLabel(index)
|
||||
end
|
||||
|
||||
@ -52,6 +55,7 @@ function updateStats(newStats)
|
||||
stats = newStats
|
||||
|
||||
for i = 1, 4 do updateButtonLabel(i) end
|
||||
updateSave()
|
||||
elseif newStats then
|
||||
printToAll("Provided new stats are incomplete or incorrectly formatted.", "Red")
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
local connections = {}
|
||||
|
||||
function onSave()
|
||||
return JSON.encode({ connections = connections })
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode({ connections = connections })
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
@ -13,6 +13,7 @@ function onLoad(savedData)
|
||||
|
||||
addHotkey("Drawing Tool: Reset", function()
|
||||
connections = {}
|
||||
updateSave()
|
||||
processLines()
|
||||
end)
|
||||
addHotkey("Drawing Tool: Redraw", processLines)
|
||||
@ -74,6 +75,7 @@ function addPair(obj1, obj2)
|
||||
|
||||
if not connections[guid1] then connections[guid1] = {} end
|
||||
connections[guid1][guid2] = not connections[guid1][guid2]
|
||||
updateSave()
|
||||
end
|
||||
|
||||
function processLines()
|
||||
|
@ -1,5 +1,5 @@
|
||||
function onSave()
|
||||
return JSON.encode(zone and zone.getGUID())
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode(zone and zone.getGUID())
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
@ -22,6 +22,7 @@ function enable()
|
||||
scale = { scale.x * 2, 7, scale.z * 2 }
|
||||
})
|
||||
zone.setName("TokenDiscardZone")
|
||||
updateSave()
|
||||
setMenu(false)
|
||||
end
|
||||
|
||||
@ -30,6 +31,7 @@ function disable()
|
||||
zone.destruct()
|
||||
zone = nil
|
||||
end
|
||||
updateSave()
|
||||
setMenu(true)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user