mythos area bugfix
This commit is contained in:
parent
34fa7ea7e8
commit
edc2cc6fab
@ -12,8 +12,8 @@ local tokenManager = require("core/token/TokenManager")
|
|||||||
-- general setup
|
-- general setup
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
ENCOUNTER_DECK_POS = {-3.93, 1, 5.76}
|
ENCOUNTER_DECK_POS = { -3.93, 1, 5.76 }
|
||||||
ENCOUNTER_DECK_DISCARD_POSITION = {-3.85, 1, 10.38}
|
ENCOUNTER_DECK_DISCARD_POSITION = { -3.85, 1, 10.38 }
|
||||||
|
|
||||||
-- GUIDs that will not be interactable (e.g. parts of the table)
|
-- GUIDs that will not be interactable (e.g. parts of the table)
|
||||||
local NOT_INTERACTABLE = {
|
local NOT_INTERACTABLE = {
|
||||||
@ -36,7 +36,7 @@ chaosTokens = {}
|
|||||||
local chaosTokensLastMat = nil
|
local chaosTokensLastMat = nil
|
||||||
|
|
||||||
local bagSearchers = {}
|
local bagSearchers = {}
|
||||||
local MAT_COLORS = {"White", "Orange", "Green", "Red"}
|
local MAT_COLORS = { "White", "Orange", "Green", "Red" }
|
||||||
local hideTitleSplashWaitFunctionId = nil
|
local hideTitleSplashWaitFunctionId = nil
|
||||||
|
|
||||||
-- online functionality related variables
|
-- online functionality related variables
|
||||||
@ -113,7 +113,12 @@ local tokenDrawingStats = {
|
|||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
-- saving state of optionPanel to restore later
|
-- saving state of optionPanel to restore later
|
||||||
function onSave() return JSON.encode({ optionPanel = optionPanel, acknowledgedUpgradeVersions = acknowledgedUpgradeVersions }) end
|
function onSave()
|
||||||
|
return JSON.encode({
|
||||||
|
optionPanel = optionPanel,
|
||||||
|
acknowledgedUpgradeVersions = acknowledgedUpgradeVersions
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
function onLoad(savedData)
|
function onLoad(savedData)
|
||||||
if savedData then
|
if savedData then
|
||||||
@ -282,8 +287,8 @@ function handleStatTrackerClick(_, _, isRightClick)
|
|||||||
if isRightClick then
|
if isRightClick then
|
||||||
resetChaosTokenStatTracker()
|
resetChaosTokenStatTracker()
|
||||||
else
|
else
|
||||||
local squidKing = "Nobody"
|
local squidKing = "Nobody"
|
||||||
local maxSquid = 0
|
local maxSquid = 0
|
||||||
local foundAnyStats = false
|
local foundAnyStats = false
|
||||||
|
|
||||||
for key, personalStats in pairs(tokenDrawingStats) do
|
for key, personalStats in pairs(tokenDrawingStats) do
|
||||||
@ -315,7 +320,7 @@ function handleStatTrackerClick(_, _, isRightClick)
|
|||||||
if totalCount > 0 then
|
if totalCount > 0 then
|
||||||
foundAnyStats = true
|
foundAnyStats = true
|
||||||
printToAll("------------------------------")
|
printToAll("------------------------------")
|
||||||
printToAll(playerName .. " Stats", playerColor)
|
printToAll(playerName .. " Stats", playerColor)
|
||||||
|
|
||||||
for tokenName, value in pairs(personalStats) do
|
for tokenName, value in pairs(personalStats) do
|
||||||
if value ~= 0 then
|
if value ~= 0 then
|
||||||
@ -329,7 +334,7 @@ function handleStatTrackerClick(_, _, isRightClick)
|
|||||||
-- detect if any player drew tokens
|
-- detect if any player drew tokens
|
||||||
if foundAnyStats then
|
if foundAnyStats then
|
||||||
printToAll("------------------------------")
|
printToAll("------------------------------")
|
||||||
printToAll(squidKing .. " is an auto-fail magnet.", {255, 0, 0})
|
printToAll(squidKing .. " is an auto-fail magnet.", { 255, 0, 0 })
|
||||||
else
|
else
|
||||||
printToAll("No tokens have been drawn yet.", "Yellow")
|
printToAll("No tokens have been drawn yet.", "Yellow")
|
||||||
end
|
end
|
||||||
@ -358,11 +363,11 @@ function createSetupButtons(args)
|
|||||||
if data ~= nil then
|
if data ~= nil then
|
||||||
local buttonParameters = {}
|
local buttonParameters = {}
|
||||||
buttonParameters.function_owner = args.object
|
buttonParameters.function_owner = args.object
|
||||||
buttonParameters.position = {0, 0.1, -0.15}
|
buttonParameters.position = { 0, 0.1, -0.15 }
|
||||||
buttonParameters.scale = {0.47, 1, 0.47}
|
buttonParameters.scale = { 0.47, 1, 0.47 }
|
||||||
buttonParameters.height = 200
|
buttonParameters.height = 200
|
||||||
buttonParameters.width = 1150
|
buttonParameters.width = 1150
|
||||||
buttonParameters.color = {0.87, 0.8, 0.7}
|
buttonParameters.color = { 0.87, 0.8, 0.7 }
|
||||||
|
|
||||||
if data.easy ~= nil then
|
if data.easy ~= nil then
|
||||||
buttonParameters.label = "Easy"
|
buttonParameters.label = "Easy"
|
||||||
@ -490,7 +495,6 @@ function getChaosBagState()
|
|||||||
end
|
end
|
||||||
|
|
||||||
return tokens
|
return tokens
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- respawns the chaos bag with a new state of tokens
|
-- respawns the chaos bag with a new state of tokens
|
||||||
@ -519,7 +523,7 @@ function setChaosBagState(tokenList)
|
|||||||
-- overwrite chaos bag content and respawn it
|
-- overwrite chaos bag content and respawn it
|
||||||
chaosbagData.ContainedObjects = containedObjects
|
chaosbagData.ContainedObjects = containedObjects
|
||||||
chaosbag.destruct()
|
chaosbag.destruct()
|
||||||
spawnObjectData({data = chaosbagData})
|
spawnObjectData({ data = chaosbagData })
|
||||||
|
|
||||||
-- remove tokens that are still in play
|
-- remove tokens that are still in play
|
||||||
for _, token in pairs(chaosTokens) do
|
for _, token in pairs(chaosTokens) do
|
||||||
@ -548,7 +552,7 @@ function spawnChaosToken(id)
|
|||||||
type = 'Custom_Tile',
|
type = 'Custom_Tile',
|
||||||
position = { 0.49, 3, 0 },
|
position = { 0.49, 3, 0 },
|
||||||
scale = { 0.81, 1.0, 0.81 },
|
scale = { 0.81, 1.0, 0.81 },
|
||||||
rotation = {0, 270, 0},
|
rotation = { 0, 270, 0 },
|
||||||
callback_function = function(obj)
|
callback_function = function(obj)
|
||||||
obj.setName(ID_URL_MAP[id].name)
|
obj.setName(ID_URL_MAP[id].name)
|
||||||
chaosbag.putObject(obj)
|
chaosbag.putObject(obj)
|
||||||
@ -598,7 +602,7 @@ function emptyChaosBag()
|
|||||||
|
|
||||||
local chaosbag = findChaosBag()
|
local chaosbag = findChaosBag()
|
||||||
for _, object in ipairs(chaosbag.getObjects()) do
|
for _, object in ipairs(chaosbag.getObjects()) do
|
||||||
chaosbag.takeObject({callback_function = function(item) item.destruct() end})
|
chaosbag.takeObject({ callback_function = function(item) item.destruct() end })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -623,7 +627,7 @@ end
|
|||||||
function onClick_select(player, params)
|
function onClick_select(player, params)
|
||||||
params = JSON.decode(urldecode(params))
|
params = JSON.decode(urldecode(params))
|
||||||
local url = SOURCE_REPO .. '/' .. params.url
|
local url = SOURCE_REPO .. '/' .. params.url
|
||||||
local request = WebRequest.get(url, function (request) complete_obj_download(request, params) end )
|
local request = WebRequest.get(url, function(request) complete_obj_download(request, params) end)
|
||||||
requestObj = request
|
requestObj = request
|
||||||
startLuaCoroutine(Global, 'downloadCoroutine')
|
startLuaCoroutine(Global, 'downloadCoroutine')
|
||||||
end
|
end
|
||||||
@ -675,7 +679,8 @@ function update_list(objects)
|
|||||||
for _, v in ipairs(objects) do
|
for _, v in ipairs(objects) do
|
||||||
local s = JSON.encode(v);
|
local s = JSON.encode(v);
|
||||||
table.insert(update_children.children,
|
table.insert(update_children.children,
|
||||||
{ tag = 'Text',
|
{
|
||||||
|
tag = 'Text',
|
||||||
value = v.name,
|
value = v.name,
|
||||||
attributes = { onClick = 'onClick_select(' .. urlencode(JSON.encode(v)) .. ')', alignment = 'MiddleLeft' }
|
attributes = { onClick = 'onClick_select(' .. urlencode(JSON.encode(v)) .. ')', alignment = 'MiddleLeft' }
|
||||||
})
|
})
|
||||||
@ -709,24 +714,24 @@ function complete_obj_download(request, params)
|
|||||||
print('error: ' .. request.error)
|
print('error: ' .. request.error)
|
||||||
else
|
else
|
||||||
if pcall(function()
|
if pcall(function()
|
||||||
local replaced_object
|
local replaced_object
|
||||||
pcall(function()
|
pcall(function()
|
||||||
if params.replace then
|
if params.replace then
|
||||||
replaced_object = getObjectFromGUID(params.replace)
|
replaced_object = getObjectFromGUID(params.replace)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
local json = request.text
|
local json = request.text
|
||||||
if replaced_object then
|
if replaced_object then
|
||||||
local pos = replaced_object.getPosition()
|
local pos = replaced_object.getPosition()
|
||||||
local rot = replaced_object.getRotation()
|
local rot = replaced_object.getRotation()
|
||||||
destroyObject(replaced_object)
|
destroyObject(replaced_object)
|
||||||
Wait.frames(function()
|
Wait.frames(function()
|
||||||
spawnObjectJSON({json = json, position = pos, rotation = rot})
|
spawnObjectJSON({ json = json, position = pos, rotation = rot })
|
||||||
end, 1)
|
end, 1)
|
||||||
else
|
else
|
||||||
spawnObjectJSON({json = json})
|
spawnObjectJSON({ json = json })
|
||||||
end
|
end
|
||||||
end) then
|
end) then
|
||||||
print('Object loaded.')
|
print('Object loaded.')
|
||||||
else
|
else
|
||||||
print('Error loading object.')
|
print('Error loading object.')
|
||||||
@ -749,7 +754,7 @@ function completed_list_update(request)
|
|||||||
print('error: ' .. request.error)
|
print('error: ' .. request.error)
|
||||||
else
|
else
|
||||||
local json_response = nil
|
local json_response = nil
|
||||||
if pcall(function () json_response = JSON.decode(request.text) end) then
|
if pcall(function() json_response = JSON.decode(request.text) end) then
|
||||||
library = json_response
|
library = json_response
|
||||||
update_window_content(UI.getValue('title'))
|
update_window_content(UI.getValue('title'))
|
||||||
else
|
else
|
||||||
@ -774,13 +779,13 @@ end
|
|||||||
|
|
||||||
function urlencode(str)
|
function urlencode(str)
|
||||||
local str = string.gsub(str, "([^A-Za-z0-9-_.~])",
|
local str = string.gsub(str, "([^A-Za-z0-9-_.~])",
|
||||||
function (c) return string.format("%%%02X", string.byte(c)) end)
|
function(c) return string.format("%%%02X", string.byte(c)) end)
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
function urldecode(str)
|
function urldecode(str)
|
||||||
local str = string.gsub(str, "%%(%x%x)",
|
local str = string.gsub(str, "%%(%x%x)",
|
||||||
function (h) return string.char(tonumber(h, 16)) end)
|
function(h) return string.char(tonumber(h, 16)) end)
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -950,7 +955,7 @@ function spawnHelperObject(name, position, rotation)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local spawnTable = {position = position}
|
local spawnTable = { position = position }
|
||||||
|
|
||||||
-- only overrride rotation if there is one provided (object's rotation used instead)
|
-- only overrride rotation if there is one provided (object's rotation used instead)
|
||||||
if rotation then
|
if rotation then
|
||||||
@ -1043,7 +1048,6 @@ end
|
|||||||
-- splash scenario title on setup
|
-- splash scenario title on setup
|
||||||
function titleSplash(scenarioName)
|
function titleSplash(scenarioName)
|
||||||
if optionPanel['showTitleSplash'] then
|
if optionPanel['showTitleSplash'] then
|
||||||
|
|
||||||
-- if there's any ongoing title being displayed, hide it and cancel the waiting function
|
-- if there's any ongoing title being displayed, hide it and cancel the waiting function
|
||||||
if hideTitleSplashWaitFunctionId then
|
if hideTitleSplashWaitFunctionId then
|
||||||
Wait.stop(hideTitleSplashWaitFunctionId)
|
Wait.stop(hideTitleSplashWaitFunctionId)
|
||||||
@ -1109,10 +1113,10 @@ function updateNotificationLoading()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- update the XML UI
|
-- update the XML UI
|
||||||
UI.setValue("notificationHeader", "New version available: ".. modMeta["latestVersion"])
|
UI.setValue("notificationHeader", "New version available: " .. modMeta["latestVersion"])
|
||||||
UI.setValue("releaseHighlightText", highlightText)
|
UI.setValue("releaseHighlightText", highlightText)
|
||||||
UI.setAttribute("highlightRow", "preferredHeight", 20*#highlights)
|
UI.setAttribute("highlightRow", "preferredHeight", 20 * #highlights)
|
||||||
UI.setAttribute("updateNotification", "height", 20*#highlights + 125)
|
UI.setAttribute("updateNotification", "height", 20 * #highlights + 125)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- triggered by clicking on the Finn Icon
|
-- triggered by clicking on the Finn Icon
|
||||||
|
@ -8,7 +8,7 @@ do
|
|||||||
|
|
||||||
-- returns the chaos token metadata (if provided through scenario reference card)
|
-- returns the chaos token metadata (if provided through scenario reference card)
|
||||||
MythosAreaApi.returnTokenData = function()
|
MythosAreaApi.returnTokenData = function()
|
||||||
getMythosArea().call("returnTokenData")
|
return getMythosArea().call("returnTokenData")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- draw an encounter card to the requested position/rotation
|
-- draw an encounter card to the requested position/rotation
|
||||||
|
Loading…
Reference in New Issue
Block a user