updated onLoad functions
This commit is contained in:
parent
f41f4f9107
commit
7cb3545cab
@ -11,6 +11,8 @@ local phaseImages = {
|
|||||||
"http://cloud-3.steamusercontent.com/ugc/982233321870237261/C287CAED2423970F33E72D6C7415CBEC6794C533/"
|
"http://cloud-3.steamusercontent.com/ugc/982233321870237261/C287CAED2423970F33E72D6C7415CBEC6794C533/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local phaseId, broadcastChange
|
||||||
|
|
||||||
function onSave()
|
function onSave()
|
||||||
return JSON.encode({
|
return JSON.encode({
|
||||||
phaseId = phaseId,
|
phaseId = phaseId,
|
||||||
|
@ -55,9 +55,9 @@ function onSave()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- loading data, button creation and initial layouting
|
-- loading data, button creation and initial layouting
|
||||||
function onLoad(saveState)
|
function onLoad(savedData)
|
||||||
if saveState ~= nil and saveState ~= "" then
|
if savedData and savedData ~= "" then
|
||||||
local loadedData = JSON.decode(saveState)
|
local loadedData = JSON.decode(savedData)
|
||||||
tokenPrecedence = loadedData.tokenPrecedence
|
tokenPrecedence = loadedData.tokenPrecedence
|
||||||
percentage = loadedData.percentage
|
percentage = loadedData.percentage
|
||||||
includeDrawnTokens = loadedData.includeDrawnTokens
|
includeDrawnTokens = loadedData.includeDrawnTokens
|
||||||
|
@ -15,7 +15,7 @@ val = 0
|
|||||||
function onSave() return JSON.encode({ val, options }) end
|
function onSave() return JSON.encode({ val, options }) end
|
||||||
|
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
if savedData ~= "" then
|
if savedData and savedData ~= "" then
|
||||||
local loadedData = JSON.decode(savedData)
|
local loadedData = JSON.decode(savedData)
|
||||||
val = loadedData[1]
|
val = loadedData[1]
|
||||||
options = loadedData[2]
|
options = loadedData[2]
|
||||||
|
@ -5,21 +5,20 @@ val = 0
|
|||||||
function onSave() return JSON.encode(val) end
|
function onSave() return JSON.encode(val) end
|
||||||
|
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
if savedData ~= nil then
|
if savedData and savedData ~= "" then
|
||||||
val = JSON.decode(savedData)
|
val = JSON.decode(savedData)
|
||||||
end
|
end
|
||||||
|
|
||||||
local name = self.getName()
|
local name = self.getName()
|
||||||
local position = {}
|
local position = { 0, 0.06, 0 }
|
||||||
|
|
||||||
|
-- set position of label depending on object
|
||||||
if name == "Damage" or name == "Resources" or name == "Resource Counter" then
|
if name == "Damage" or name == "Resources" or name == "Resource Counter" then
|
||||||
position = { 0, 0.06, 0.1 }
|
position = { 0, 0.06, 0.1 }
|
||||||
elseif name == "Horror" then
|
elseif name == "Horror" then
|
||||||
position = { -0.025, 0.06, -0.025 }
|
position = { -0.025, 0.06, -0.025 }
|
||||||
elseif name == "Elder Sign Counter" or name == "Auto-fail Counter" then
|
elseif name == "Elder Sign Counter" or name == "Auto-fail Counter" then
|
||||||
position = { 0, 0.1, 0 }
|
position = { 0, 0.1, 0 }
|
||||||
else
|
|
||||||
position = { 0, 0.06, 0 }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self.createButton({
|
self.createButton({
|
||||||
@ -35,6 +34,7 @@ function onLoad(savedData)
|
|||||||
color = { 0, 0, 0, 0 }
|
color = { 0, 0, 0, 0 }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- add context menu entries
|
||||||
self.addContextMenuItem("Add 5", function() updateVal(val + 5) end)
|
self.addContextMenuItem("Add 5", function() updateVal(val + 5) end)
|
||||||
self.addContextMenuItem("Subtract 5", function() updateVal(val - 5) end)
|
self.addContextMenuItem("Subtract 5", function() updateVal(val - 5) end)
|
||||||
self.addContextMenuItem("Add 10", function() updateVal(val + 10) end)
|
self.addContextMenuItem("Add 10", function() updateVal(val + 10) end)
|
||||||
|
@ -127,19 +127,18 @@ function onSave()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
if savedData then
|
if savedData and savedData ~= "" then
|
||||||
loadedData = JSON.decode(savedData)
|
local loadedData = JSON.decode(savedData)
|
||||||
optionPanel = loadedData.optionPanel
|
optionPanel = loadedData.optionPanel
|
||||||
acknowledgedUpgradeVersions = loadedData.acknowledgedUpgradeVersions
|
acknowledgedUpgradeVersions = loadedData.acknowledgedUpgradeVersions
|
||||||
updateOptionPanelState()
|
chaosTokensLastMatGUID = loadedData.chaosTokensLastMatGUID
|
||||||
|
|
||||||
-- restore saved state for drawn chaos tokens
|
-- restore saved state for drawn chaos tokens
|
||||||
for _, guid in ipairs(loadedData.chaosTokensGUID or {}) do
|
for _, guid in ipairs(loadedData.chaosTokensGUID or {}) do
|
||||||
table.insert(chaosTokens, getObjectFromGUID(guid))
|
table.insert(chaosTokens, getObjectFromGUID(guid))
|
||||||
end
|
end
|
||||||
chaosTokensLastMatGUID = loadedData.chaosTokensLastMatGUID
|
|
||||||
else
|
updateOptionPanelState()
|
||||||
print("Saved state could not be found!")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, guid in ipairs(NOT_INTERACTABLE) do
|
for _, guid in ipairs(NOT_INTERACTABLE) do
|
||||||
|
@ -7,9 +7,10 @@ useClickableCounters = false
|
|||||||
function onSave() return JSON.encode(useClickableCounters) end
|
function onSave() return JSON.encode(useClickableCounters) end
|
||||||
|
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
if savedData ~= nil then
|
if savedData and savedData ~= "" then
|
||||||
useClickableCounters = JSON.decode(savedData)
|
useClickableCounters = JSON.decode(savedData)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.createButton({
|
self.createButton({
|
||||||
label = "0",
|
label = "0",
|
||||||
click_function = "removeAllPlayerClues",
|
click_function = "removeAllPlayerClues",
|
||||||
@ -23,6 +24,7 @@ function onLoad(savedData)
|
|||||||
font_color = { 1, 1, 1, 100 },
|
font_color = { 1, 1, 1, 100 },
|
||||||
color = { 0, 0, 0, 0 }
|
color = { 0, 0, 0, 0 }
|
||||||
})
|
})
|
||||||
|
|
||||||
Wait.time(sumClues, 2, -1)
|
Wait.time(sumClues, 2, -1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ local collisionEnabled = false
|
|||||||
local currentScenario, useFrontData, tokenData
|
local currentScenario, useFrontData, tokenData
|
||||||
local TRASH, DATA_HELPER
|
local TRASH, DATA_HELPER
|
||||||
|
|
||||||
function onLoad(saveState)
|
function onLoad(savedData)
|
||||||
if saveState ~= nil then
|
if savedData and savedData ~= "" then
|
||||||
local loadedState = JSON.decode(saveState) or {}
|
local loadedState = JSON.decode(savedData) or {}
|
||||||
currentScenario = loadedState.currentScenario or ""
|
currentScenario = loadedState.currentScenario or ""
|
||||||
useFrontData = loadedState.useFrontData or true
|
useFrontData = loadedState.useFrontData or true
|
||||||
tokenData = loadedState.tokenData or {}
|
tokenData = loadedState.tokenData or {}
|
||||||
|
@ -82,7 +82,7 @@ function onSave()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
if savedData ~= "" then
|
if savedData and savedData ~= "" then
|
||||||
local loadedData = JSON.decode(savedData)
|
local loadedData = JSON.decode(savedData)
|
||||||
visibility = loadedData.visibility
|
visibility = loadedData.visibility
|
||||||
claims = loadedData.claims
|
claims = loadedData.claims
|
||||||
|
@ -60,12 +60,16 @@ function onSave()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
self.interactable = false -- this needs to be here since the playarea will be reloaded when the image changes
|
if savedData and savedData ~= "" then
|
||||||
local loadedData = JSON.decode(savedData) or {}
|
local loadedData = JSON.decode(savedData) or {}
|
||||||
locations = loadedData.trackedLocations or {}
|
locations = loadedData.trackedLocations or {}
|
||||||
currentScenario = loadedData.currentScenario
|
currentScenario = loadedData.currentScenario
|
||||||
connectionColor = loadedData.connectionColor or { 0.4, 0.4, 0.4, 1 }
|
connectionColor = loadedData.connectionColor or { 0.4, 0.4, 0.4, 1 }
|
||||||
connectionsEnabled = loadedData.connectionsEnabled or true
|
connectionsEnabled = loadedData.connectionsEnabled or true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- this needs to be here since the playarea will be reloaded when the image changes
|
||||||
|
self.interactable = false
|
||||||
|
|
||||||
Wait.time(function() collisionEnabled = true end, 0.1)
|
Wait.time(function() collisionEnabled = true end, 0.1)
|
||||||
end
|
end
|
||||||
|
@ -6,6 +6,12 @@ local typeIndex, selectionIndex, plainNameCache
|
|||||||
function onSave() return JSON.encode({ typeIndex = typeIndex, selectionIndex = selectionIndex }) end
|
function onSave() return JSON.encode({ typeIndex = typeIndex, selectionIndex = selectionIndex }) end
|
||||||
|
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
|
if savedData and savedData ~= "" then
|
||||||
|
local loadedData = JSON.decode(savedData) or {}
|
||||||
|
typeIndex = loadedData.typeIndex or 1
|
||||||
|
selectionIndex = loadedData.selectionIndex or 1
|
||||||
|
end
|
||||||
|
|
||||||
self.createButton({
|
self.createButton({
|
||||||
function_owner = self,
|
function_owner = self,
|
||||||
click_function = "onClick_toggleGallery",
|
click_function = "onClick_toggleGallery",
|
||||||
@ -16,9 +22,6 @@ function onLoad(savedData)
|
|||||||
color = { 1, 1, 1, 0 }
|
color = { 1, 1, 1, 0 }
|
||||||
})
|
})
|
||||||
|
|
||||||
local loadedData = JSON.decode(savedData) or {}
|
|
||||||
typeIndex = loadedData.typeIndex or 1
|
|
||||||
selectionIndex = loadedData.selectionIndex or 1
|
|
||||||
Wait.time(updatePlayAreaGallery, 0.5)
|
Wait.time(updatePlayAreaGallery, 0.5)
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
end
|
end
|
||||||
|
@ -2,15 +2,13 @@ local spawnedCardGuids = {}
|
|||||||
|
|
||||||
function onSave() return JSON.encode({ cards = spawnedCardGuids }) end
|
function onSave() return JSON.encode({ cards = spawnedCardGuids }) end
|
||||||
|
|
||||||
function onLoad(saveState)
|
function onLoad(savedData)
|
||||||
if saveState ~= nil then
|
if savedData and savedData ~= "" then
|
||||||
local saveTable = JSON.decode(saveState) or {}
|
local loadedData = JSON.decode(savedData) or {}
|
||||||
spawnedCardGuids = saveTable.cards or {}
|
spawnedCardGuids = loadedData.cards or {}
|
||||||
end
|
end
|
||||||
createResetMenuItems()
|
|
||||||
end
|
|
||||||
|
|
||||||
function createResetMenuItems()
|
-- context menu entries
|
||||||
self.addContextMenuItem("Reset All", resetAll)
|
self.addContextMenuItem("Reset All", resetAll)
|
||||||
self.addContextMenuItem("Reset Locations", resetAllLocations)
|
self.addContextMenuItem("Reset Locations", resetAllLocations)
|
||||||
self.addContextMenuItem("Reset Player Cards", resetAllAssetAndEvents)
|
self.addContextMenuItem("Reset Player Cards", resetAllAssetAndEvents)
|
||||||
|
@ -103,13 +103,13 @@ function onSave()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
arkhamDb.initialize()
|
if savedData and savedData ~= "" then
|
||||||
if (savedData ~= nil) then
|
|
||||||
local saveState = JSON.decode(savedData) or { }
|
local saveState = JSON.decode(savedData) or { }
|
||||||
if (saveState.spawnBagState ~= nil) then
|
if saveState.spawnBagState ~= nil then
|
||||||
spawnBag.loadFromSave(saveState.spawnBagState)
|
spawnBag.loadFromSave(saveState.spawnBagState)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
arkhamDb.initialize()
|
||||||
buildExcludedWeaknessList()
|
buildExcludedWeaknessList()
|
||||||
createButtons()
|
createButtons()
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,9 @@ function onSave() return JSON.encode(stats) end
|
|||||||
|
|
||||||
-- load stats and make buttons (left to right)
|
-- load stats and make buttons (left to right)
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
|
if savedData and savedData ~= "" then
|
||||||
stats = JSON.decode(savedData) or { 1, 1, 1, 1 }
|
stats = JSON.decode(savedData) or { 1, 1, 1, 1 }
|
||||||
|
end
|
||||||
|
|
||||||
for index = 1, 4 do
|
for index = 1, 4 do
|
||||||
local fnName = "buttonClick" .. index
|
local fnName = "buttonClick" .. index
|
||||||
|
@ -95,7 +95,14 @@ function onSave()
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function onLoad(saveState)
|
function onLoad(savedData)
|
||||||
|
if savedData and savedData ~= "" then
|
||||||
|
local loadedData = JSON.decode(savedData)
|
||||||
|
playerColor = loadedData.playerColor
|
||||||
|
activeInvestigatorId = loadedData.activeInvestigatorId
|
||||||
|
isDrawButtonVisible = loadedData.isDrawButtonVisible
|
||||||
|
end
|
||||||
|
|
||||||
self.interactable = false
|
self.interactable = false
|
||||||
|
|
||||||
-- get object references to owned objects
|
-- get object references to owned objects
|
||||||
@ -135,14 +142,6 @@ function onLoad(saveState)
|
|||||||
font_size = 180
|
font_size = 180
|
||||||
})
|
})
|
||||||
|
|
||||||
-- save state loading
|
|
||||||
local state = JSON.decode(saveState)
|
|
||||||
if state ~= nil then
|
|
||||||
playerColor = state.playerColor
|
|
||||||
activeInvestigatorId = state.activeInvestigatorId
|
|
||||||
isDrawButtonVisible = state.isDrawButtonVisible
|
|
||||||
end
|
|
||||||
|
|
||||||
showDrawButton(isDrawButtonVisible)
|
showDrawButton(isDrawButtonVisible)
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
Wait.time(function() collisionEnabled = true end, 0.1)
|
Wait.time(function() collisionEnabled = true end, 0.1)
|
||||||
|
@ -6,7 +6,9 @@ function onSave()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
|
if savedData and savedData ~= "" then
|
||||||
lines = JSON.decode(savedData) or {}
|
lines = JSON.decode(savedData) or {}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- create timer when numpad 0 is pressed
|
-- create timer when numpad 0 is pressed
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
local zone = nil
|
local zone
|
||||||
|
|
||||||
-- general code
|
-- general code
|
||||||
function onSave()
|
function onSave()
|
||||||
return JSON.encode(zone and zone.getGUID() or nil)
|
return JSON.encode(zone and zone.getGUID())
|
||||||
end
|
end
|
||||||
|
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user