Merge pull request #9 from Entrox-Licher/entrox-main

Entrox main
This commit is contained in:
Entrox-Licher 2023-08-10 17:10:21 -04:00 committed by GitHub
commit 858954b557
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 11 deletions

View File

@ -47,11 +47,13 @@ local DAMAGE_HORROR_GUIDS = {
} }
local chaosBagApi = require("chaosbag/ChaosBagApi") local chaosBagApi = require("chaosbag/ChaosBagApi")
local playAreaAPI = require("core/PlayAreaApi") local playAreaApi = require("core/PlayAreaApi")
local deckImporterApi = require("arkhamdb/DeckImporterApi") local deckImporterApi = require("arkhamdb/DeckImporterApi")
local optionPanelApi = require("core/OptionPanelApi") local optionPanelApi = require("core/OptionPanelApi")
local blessCurseApi = require("chaosbag/BlessCurseManagerApi") local blessCurseApi = require("chaosbag/BlessCurseManagerApi")
local TOUR_GUID = "0e5aa8"
local campaignBoxGUID local campaignBoxGUID
function onLoad(save_state) function onLoad(save_state)
@ -148,20 +150,25 @@ function createCampaignFromToken(importData)
deckImporterApi.setUiState(importData["decks"]) deckImporterApi.setUiState(importData["decks"])
end end
--set investigator count --set investigator count
playAreaAPI.setInvestigatorCount(importData["clueCount"]) playAreaApi.setInvestigatorCount(importData["clueCount"])
--set campaign guide page --set campaign guide page
if findCampaignGuide() then local guide = findCampaignGuide()
if guide then
Wait.condition( Wait.condition(
-- Called after the condition function returns true
function() function()
--log("Campaign Guide import successful!") log("Campaign Guide import successful!")
end, end,
-- Condition function that is called continiously until returs true or timeout is reached
function() function()
findCampaignGuide().Book.setPage(importData["guide"]) guide.Book.setPage(importData["guide"])
return findCampaignGuide().Book.getPage() == importData["guide"] return guide.Book.getPage() == importData["guide"]
end, end,
-- Amount of time in seconds until the Wait times out
1, 1,
-- Called if the Wait times out
function() function()
--log("Campaign Guide import failed!") log("Campaign Guide import failed!")
end end
) )
end end
@ -169,6 +176,8 @@ function createCampaignFromToken(importData)
function() optionPanelApi.loadSettings(importData["options"]) end, function() optionPanelApi.loadSettings(importData["options"]) end,
0.5 0.5
) )
getObjectFromGUID(TOUR_GUID).destruct()
playAreaApi.updateSurface(importData["playmat"])
broadcastToAll("Campaign successfully imported!", Color.Green) broadcastToAll("Campaign successfully imported!", Color.Green)
end end
@ -224,9 +233,10 @@ function createCampaignToken(_, playerColor, _)
bag = chaosBagApi.getChaosBagState(), bag = chaosBagApi.getChaosBagState(),
trauma = traumaValues, trauma = traumaValues,
decks = deckImporterApi.getUiState(), decks = deckImporterApi.getUiState(),
clueCount = playAreaAPI.getInvestigatorCount(), clueCount = playAreaApi.getInvestigatorCount(),
guide = campaignGuidePage, guide = campaignGuidePage,
options = optionPanelApi.getOptions() options = optionPanelApi.getOptions(),
playmat = playAreaApi.getSurface()
} }
campaignTokenData.GMNotes = JSON.encode(campaignData) campaignTokenData.GMNotes = JSON.encode(campaignData)
campaignTokenData.Nickname = os.date("%b %d ") .. getObjectFromGUID(campaignBoxGUID).getName() .. " Save" campaignTokenData.Nickname = os.date("%b %d ") .. getObjectFromGUID(campaignBoxGUID).getName() .. " Save"

View File

@ -4,6 +4,8 @@ do
local PLAY_AREA_GUID = "721ba2" local PLAY_AREA_GUID = "721ba2"
local INVESTIGATOR_COUNTER_GUID = "f182ee" local INVESTIGATOR_COUNTER_GUID = "f182ee"
local IMAGE_SWAPPER = "b7b45b"
-- Returns the current value of the investigator counter from the playmat -- Returns the current value of the investigator counter from the playmat
---@return Integer. Number of investigators currently set on the counter ---@return Integer. Number of investigators currently set on the counter
PlayAreaApi.getInvestigatorCount = function() PlayAreaApi.getInvestigatorCount = function()
@ -84,6 +86,14 @@ do
return getObjectFromGUID(PLAY_AREA_GUID).call("isInPlayArea", object) return getObjectFromGUID(PLAY_AREA_GUID).call("isInPlayArea", object)
end end
PlayAreaApi.getSurface = function()
return getObjectFromGUID(PLAY_AREA_GUID).getCustomObject().image
end
PlayAreaApi.updateSurface = function(url)
return getObjectFromGUID(IMAGE_SWAPPER).call("updateSurface", url)
end
-- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the -- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the
-- data to the local token manager instance. -- data to the local token manager instance.
---@param args Table Single-value array holding the GUID of the Custom Data Helper making the call ---@param args Table Single-value array holding the GUID of the Custom Data Helper making the call
@ -107,7 +117,5 @@ do
return getObjectFromGUID(PLAY_AREA_GUID).reload() return getObjectFromGUID(PLAY_AREA_GUID).reload()
end end
return PlayAreaApi return PlayAreaApi
end end