more features
This commit is contained in:
parent
aa635226d1
commit
aa989d7b91
@ -83,7 +83,7 @@ end
|
|||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
function importFromToken()
|
function importFromToken()
|
||||||
broadcastToAll("Campaign Import initiated")
|
broadcastToAll("Import initiated")
|
||||||
local importData = JSON.decode(coin.getGMNotes())
|
local importData = JSON.decode(coin.getGMNotes())
|
||||||
|
|
||||||
-- import the campaign data
|
-- import the campaign data
|
||||||
@ -194,8 +194,15 @@ function importFromToken()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- enable Token Removers
|
||||||
|
if importData["enableTokenRemover"] then
|
||||||
|
for _, obj in ipairs(guidReferenceApi.getObjectsByType("TokenRemover")) do
|
||||||
|
obj.call("enable")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
coin.destruct()
|
coin.destruct()
|
||||||
broadcastToAll("Campaign successfully imported!", "Green")
|
broadcastToAll("Import completed!", "Green")
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -206,7 +213,7 @@ end
|
|||||||
|
|
||||||
-- creates a campaign token with save data encoded into GM Notes based on the current state of the table
|
-- creates a campaign token with save data encoded into GM Notes based on the current state of the table
|
||||||
function exportToToken()
|
function exportToToken()
|
||||||
broadcastToAll("Campaign Export initiated")
|
broadcastToAll("Export initiated")
|
||||||
|
|
||||||
local dataToSave = {}
|
local dataToSave = {}
|
||||||
|
|
||||||
@ -294,15 +301,24 @@ function exportToToken()
|
|||||||
dataToSave.removePhaseTracker = true
|
dataToSave.removePhaseTracker = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- check if Token Removers are enabled
|
||||||
|
local tokenRemoverList = guidReferenceApi.getObjectsByType("TokenRemover")
|
||||||
|
if #tokenRemoverList > 0 then
|
||||||
|
local zoneGUID = tokenRemoverList[1].call("onSave")
|
||||||
|
if getObjectFromGUID(zoneGUID) ~= nil then
|
||||||
|
dataToSave.enableTokenRemover = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- finish the data for the campaign token
|
-- finish the data for the campaign token
|
||||||
saveTokenData.GMNotes = JSON.encode(dataToSave)
|
saveTokenData.GMNotes = JSON.encode(dataToSave)
|
||||||
saveTokenData.Nickname = os.date("%Y-%m-%d") .. " Save"
|
saveTokenData.Nickname = os.date("%Y_%m_%d") .. " Save"
|
||||||
if campaignBox then
|
if campaignBox then
|
||||||
saveTokenData.Nickname = saveTokenData.Nickname .. " " .. campaignBox.getName()
|
saveTokenData.Nickname = saveTokenData.Nickname .. " (" .. campaignBox.getName() .. ")"
|
||||||
end
|
end
|
||||||
|
|
||||||
spawnObjectData({ data = saveTokenData })
|
spawnObjectData({ data = saveTokenData })
|
||||||
broadcastToAll("Campaign successfully exported! Save coin object to import on a different save.", "Green")
|
broadcastToAll("Export completed! Save coin object to import on a different save.", "Green")
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -324,9 +340,9 @@ function findUniqueObjectWithTag(tag)
|
|||||||
if #objects == 1 then
|
if #objects == 1 then
|
||||||
return objects[1]
|
return objects[1]
|
||||||
elseif #objects == 0 then
|
elseif #objects == 0 then
|
||||||
broadcastToAll("No " .. tag .. " detected; ensure it has the correct tag.", "Red")
|
broadcastToAll("No " .. tag .. " detected; ensure it has the correct tag.", "Orange")
|
||||||
else
|
else
|
||||||
broadcastToAll("More than one " .. tag .. " detected; delete all but one.", "Red")
|
broadcastToAll("More than one " .. tag .. " detected; delete all but one.", "Orange")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ function loadData(loadedData)
|
|||||||
includeDrawnTokens = loadedData.includeDrawnTokens
|
includeDrawnTokens = loadedData.includeDrawnTokens
|
||||||
|
|
||||||
updateUI()
|
updateUI()
|
||||||
layout()
|
Wait.time(layout, 1.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- saving the precedence settings and information on the most recently loaded data
|
-- saving the precedence settings and information on the most recently loaded data
|
||||||
|
@ -2,13 +2,27 @@ do
|
|||||||
local TokenArrangerApi = {}
|
local TokenArrangerApi = {}
|
||||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||||
|
|
||||||
|
-- internal function to create a copy of the table to avoid operating on variables owned by different objects
|
||||||
|
local function deepCopy(data)
|
||||||
|
if type(data) ~= "table" then return data end
|
||||||
|
local copiedList = {}
|
||||||
|
for key, value in pairs(data) do
|
||||||
|
if type(value) == "table" then
|
||||||
|
copiedList[key] = deepCopy(value)
|
||||||
|
else
|
||||||
|
copiedList[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return copiedList
|
||||||
|
end
|
||||||
|
|
||||||
-- local function to call the token arranger, if it is on the table
|
-- local function to call the token arranger, if it is on the table
|
||||||
---@param functionName string Name of the function to cal
|
---@param functionName string Name of the function to cal
|
||||||
---@param argument? table Parameter to pass
|
---@param argument? table Parameter to pass
|
||||||
local function callIfExistent(functionName, argument)
|
local function callIfExistent(functionName, argument)
|
||||||
local tokenArranger = guidReferenceApi.getObjectByOwnerAndType("Mythos", "TokenArranger")
|
local tokenArranger = guidReferenceApi.getObjectByOwnerAndType("Mythos", "TokenArranger")
|
||||||
if tokenArranger ~= nil then
|
if tokenArranger ~= nil then
|
||||||
tokenArranger.call(functionName, argument)
|
return tokenArranger.call(functionName, argument)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,7 +43,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
TokenArrangerApi.getSaveData = function()
|
TokenArrangerApi.getSaveData = function()
|
||||||
return callIfExistent("getSaveData")
|
return deepCopy(callIfExistent("getSaveData"))
|
||||||
end
|
end
|
||||||
|
|
||||||
TokenArrangerApi.loadData = function(loadedData)
|
TokenArrangerApi.loadData = function(loadedData)
|
||||||
|
@ -85,6 +85,7 @@ local GuidReferences = {
|
|||||||
RulesReference = "d99993",
|
RulesReference = "d99993",
|
||||||
SoundCube = "3c988f",
|
SoundCube = "3c988f",
|
||||||
TokenArranger = "022907",
|
TokenArranger = "022907",
|
||||||
|
TokenRemover = "0a5a29",
|
||||||
TokenSource = "124381",
|
TokenSource = "124381",
|
||||||
TokenSpawnTracker = "e3ffc9",
|
TokenSpawnTracker = "e3ffc9",
|
||||||
TourStarter = "0e5aa8",
|
TourStarter = "0e5aa8",
|
||||||
|
@ -6,6 +6,20 @@ do
|
|||||||
return guidReferenceApi.getObjectByOwnerAndType("Mythos", "NavigationOverlayHandler")
|
return guidReferenceApi.getObjectByOwnerAndType("Mythos", "NavigationOverlayHandler")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- internal function to create a copy of the table to avoid operating on variables owned by different objects
|
||||||
|
local function deepCopy(data)
|
||||||
|
if type(data) ~= "table" then return data end
|
||||||
|
local copiedList = {}
|
||||||
|
for key, value in pairs(data) do
|
||||||
|
if type(value) == "table" then
|
||||||
|
copiedList[key] = deepCopy(value)
|
||||||
|
else
|
||||||
|
copiedList[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return copiedList
|
||||||
|
end
|
||||||
|
|
||||||
-- copies the visibility for the Navigation overlay
|
-- copies the visibility for the Navigation overlay
|
||||||
---@param startColor string Color of the player to copy from
|
---@param startColor string Color of the player to copy from
|
||||||
---@param targetColor string Color of the targeted player
|
---@param targetColor string Color of the targeted player
|
||||||
@ -33,7 +47,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
NavigationOverlayApi.getSaveData = function()
|
NavigationOverlayApi.getSaveData = function()
|
||||||
return getNOHandler().call("getSaveData")
|
return deepCopy(getNOHandler().call("getSaveData"))
|
||||||
end
|
end
|
||||||
|
|
||||||
NavigationOverlayApi.loadData = function(loadedData)
|
NavigationOverlayApi.loadData = function(loadedData)
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
local zone
|
|
||||||
|
|
||||||
-- general code
|
|
||||||
function onSave()
|
function onSave()
|
||||||
return JSON.encode(zone and zone.getGUID())
|
return JSON.encode(zone and zone.getGUID())
|
||||||
end
|
end
|
||||||
@ -12,8 +9,11 @@ function onLoad(savedData)
|
|||||||
setMenu(zone == nil)
|
setMenu(zone == nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- context menu functions
|
|
||||||
function enable()
|
function enable()
|
||||||
|
if zone ~= nil then
|
||||||
|
zone.destruct()
|
||||||
|
end
|
||||||
|
|
||||||
local scale = self.getScale()
|
local scale = self.getScale()
|
||||||
zone = spawnObject({
|
zone = spawnObject({
|
||||||
type = "ScriptingTrigger",
|
type = "ScriptingTrigger",
|
||||||
@ -26,11 +26,13 @@ function enable()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function disable()
|
function disable()
|
||||||
if zone ~= nil then zone.destruct() end
|
if zone ~= nil then
|
||||||
|
zone.destruct()
|
||||||
|
zone = nil
|
||||||
|
end
|
||||||
setMenu(true)
|
setMenu(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- core functions
|
|
||||||
function setMenu(isEnabled)
|
function setMenu(isEnabled)
|
||||||
self.clearContextMenu()
|
self.clearContextMenu()
|
||||||
if isEnabled then
|
if isEnabled then
|
||||||
|
Loading…
Reference in New Issue
Block a user