some bugfixes

This commit is contained in:
Chr1Z93 2024-09-30 12:46:53 +02:00
parent 076ce45b9f
commit dccf5daacc
4 changed files with 53 additions and 34 deletions

View File

@ -2472,25 +2472,17 @@ end
-- generates the data to spawn an infinite bag of a specific type of resources -- generates the data to spawn an infinite bag of a specific type of resources
function TokenManager.getDataForInfiniteBag(tokenType) function TokenManager.getDataForInfiniteBag(tokenType)
TokenManager.initTokenTemplates() TokenManager.initTokenTemplates()
local tokenTemplate = tokenTemplates["resource"] local template = deepCopy(tokenTemplates["resource"])
local subTypeData local subTypeStateId = stateTable[tokenType]
local subTypeStateId local subTypeData = template["States"][subTypeStateId]
for stateId, objData in pairs(tokenTemplate["States"]) do
if tokenType == objData["Memo"] then
subTypeStateId = stateId
subTypeData = objData
break
end
end
-- add states to data -- add states to data
subTypeData["States"] = tokenTemplate["States"] subTypeData["States"] = template["States"]
-- add "1" state and remove the current state -- add "1" state and remove the current state
subTypeData["States"]["1"] = tokenTemplate subTypeData["States"][1] = template
subTypeData["States"]["1"]["States"] = nil subTypeData["States"][1]["States"] = nil
subTypeData["States"][tostring(subTypeStateId)] = nil subTypeData["States"][subTypeStateId] = nil
return subTypeData return subTypeData
--local spawnData = {} --local spawnData = {}
@ -2565,3 +2557,17 @@ function getColoredName(playerColor)
-- add bb-code -- add bb-code
return "[" .. Color.fromString(playerColor):toHex() .. "]" .. displayName .. "[-]" return "[" .. Color.fromString(playerColor):toHex() .. "]" .. displayName .. "[-]"
end end
-- creates a deep copy of a table
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

View File

@ -89,19 +89,14 @@ do
function TokenManagerApi.maybeReplenishCard(card, uses) function TokenManagerApi.maybeReplenishCard(card, uses)
Global.call("callTable", { Global.call("callTable", {
{ "TokenManager", "maybeReplenishCard" }, { "TokenManager", "maybeReplenishCard" },
{ { card = card, uses = uses }
card = card,
uses = uses
}
}) })
end end
function TokenManagerApi.getDataForInfiniteBag(tokenType) function TokenManagerApi.getDataForInfiniteBag(tokenType)
Global.call("callTable", { return Global.call("callTable", {
{ "TokenManager", "getDataForInfiniteBag" }, { "TokenManager", "getDataForInfiniteBag" },
{ tokenType
tokenType = tokenType
}
}) })
end end

View File

@ -272,9 +272,15 @@ function round(num, numDecimalPlaces)
end end
-- updates the internal "messageColor" which is used for print/broadcast statements if no player is seated -- updates the internal "messageColor" which is used for print/broadcast statements if no player is seated
---@param clickedByColor string Colorstring of player who clicked a button ---@param clickedByColor? string Colorstring of player who clicked a button
function updateMessageColor(clickedByColor) function updateMessageColor(clickedByColor)
messageColor = Player[playerColor].seated and playerColor or clickedByColor if Player[playerColor].seated then
messageColor = playerColor
elseif clickedByColor and Player[clickedByColor].seated then
messageColor = clickedByColor
else
messageColor = Player.getPlayers()[1].color
end
end end
--------------------------------------------------------- ---------------------------------------------------------
@ -1340,6 +1346,8 @@ end
-- does something for specific investigators when they are loaded -- does something for specific investigators when they are loaded
function newInvestigatorCallback(newId) function newInvestigatorCallback(newId)
updateMessageColor()
-- remove existing object that was placed for a specific investigator -- remove existing object that was placed for a specific investigator
local obj = guidReferenceApi.getObjectByOwnerAndType(playerColor, "InvestigatorSpecifics") local obj = guidReferenceApi.getObjectByOwnerAndType(playerColor, "InvestigatorSpecifics")
if obj ~= nil then if obj ~= nil then
@ -1350,13 +1358,17 @@ function newInvestigatorCallback(newId)
if newId == "01005-p" or newId == "01005-pf" then if newId == "01005-p" or newId == "01005-pf" then
-- parallel Wendy Adams -- parallel Wendy Adams
printToColor( printToColor(
"There's a Game Key for parallel Wendy to add sealing options to any card:" .. "Wendy Adams: There's a Game Key to add sealing options to any card:" ..
" Top menu bar > Options > Game Keys", messageColor) " Top menu bar > Options > Game Keys", messageColor)
elseif newId == "06003" then elseif newId == "06003" then
-- Tony Morgan -- Tony Morgan
local spawnedObj = spawnObjectData({ data = getDataForInfiniteBag("bounty") }) local spawnedObj = spawnObjectData({
data = getDataForInfiniteBag("bounty"),
position = zones.getZonePosition(playerColor, "SetAside7"),
rotation = self.getRotation()
})
guidReferenceApi.editIndex(playerColor, "InvestigatorSpecifics", spawnedObj.getGUID()) guidReferenceApi.editIndex(playerColor, "InvestigatorSpecifics", spawnedObj.getGUID())
printToColor("We've spawned an infinite bag of bounty tokens for convenience near your playermat.", messageColor) printToColor("Tony Morgan: Spawned an infinite bag of bounty tokens near your playermat.", messageColor)
elseif newId == "08004" then elseif newId == "08004" then
-- Norman Withers -- Norman Withers
printToColor( printToColor(
@ -1364,9 +1376,13 @@ function newInvestigatorCallback(newId)
"and then the mod should keep it flipped throughout the game.", messageColor) "and then the mod should keep it flipped throughout the game.", messageColor)
elseif newId == "09015" then elseif newId == "09015" then
-- Darrell Simmons -- Darrell Simmons
local spawnedObj = spawnObjectData({ data = getDataForInfiniteBag("evidence") }) local spawnedObj = spawnObjectData({
data = getDataForInfiniteBag("evidence"),
position = zones.getZonePosition(playerColor, "SetAside7"),
rotation = self.getRotation()
})
guidReferenceApi.editIndex(playerColor, "InvestigatorSpecifics", spawnedObj.getGUID()) guidReferenceApi.editIndex(playerColor, "InvestigatorSpecifics", spawnedObj.getGUID())
printToColor("We've spawned an infinite bag of evidence tokens for convenience near your playermat.", messageColor) printToColor("Darrell Simons: Spawned an infinite bag of evidence tokens near your playermat.", messageColor)
elseif newId == "89001" then elseif newId == "89001" then
-- Subject 5U-21 -- Subject 5U-21
local sourceBag = guidReferenceApi.getObjectByOwnerAndType("Mythos", "OptionPanelSource") local sourceBag = guidReferenceApi.getObjectByOwnerAndType("Mythos", "OptionPanelSource")
@ -1382,13 +1398,15 @@ function newInvestigatorCallback(newId)
break break
end end
end end
printToColor("We've spawned a helper to track the classes of devoured cards near your playermat. " .. printToColor("Subject 5U-21: Spawned a helper to track the classes of devoured cards near your playermat. " ..
"Note that this and 'Ravenous' will work with the Attachment Helper from the option panel.", messageColor) "Note that this and 'Ravenous' will work with the Attachment Helper from the option panel.", messageColor)
end end
end end
function getDataForInfiniteBag(tokenType) function getDataForInfiniteBag(tokenType)
local tokenData = tokenManagerApi.getDataForInfiniteBag(tokenType) local tokenData = tokenManagerApi.getDataForInfiniteBag(tokenType)
log(tokenData)
return tokenData
end end
-- returns the mini ID for the currently placed investigator -- returns the mini ID for the currently placed investigator

View File

@ -80,7 +80,7 @@ do
zoneData["White"]["SetAside5"] = { 2.78, 0, 0.042 } zoneData["White"]["SetAside5"] = { 2.78, 0, 0.042 }
zoneData["White"]["SetAside6"] = { 2.78, 0, 0.605 } zoneData["White"]["SetAside6"] = { 2.78, 0, 0.605 }
zoneData["White"]["UnderSetAside6"] = { 2.93, 0, 0.805 } zoneData["White"]["UnderSetAside6"] = { 2.93, 0, 0.805 }
zoneData["White"]["SetAside7"] = { 3.21, 0, 0.705 } zoneData["White"]["SetAside7"] = { 2.85, 0, 1.650 }
zoneData["Orange"] = {} zoneData["Orange"] = {}
zoneData["Orange"]["Investigator"] = commonZones["Investigator"] zoneData["Orange"]["Investigator"] = commonZones["Investigator"]
@ -113,7 +113,7 @@ do
zoneData["Orange"]["SetAside5"] = { -2.78, 0, 0.042 } zoneData["Orange"]["SetAside5"] = { -2.78, 0, 0.042 }
zoneData["Orange"]["SetAside6"] = { -2.78, 0, 0.605 } zoneData["Orange"]["SetAside6"] = { -2.78, 0, 0.605 }
zoneData["Orange"]["UnderSetAside6"] = { -2.93, 0, 0.805 } zoneData["Orange"]["UnderSetAside6"] = { -2.93, 0, 0.805 }
zoneData["Orange"]["SetAside7"] = { -3.21, 0, 0.705 } zoneData["Orange"]["SetAside7"] = { -2.85, 0, 1.650 }
-- Green positions are the same as White and Red the same as Orange -- Green positions are the same as White and Red the same as Orange
zoneData["Red"] = zoneData["Orange"] zoneData["Red"] = zoneData["Orange"]