code maintenance
This commit is contained in:
parent
02349f57f7
commit
31b4613caf
@ -1,60 +0,0 @@
|
||||
{
|
||||
"AltLookAngle": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"Autoraise": true,
|
||||
"ColorDiffuse": {
|
||||
"b": 1,
|
||||
"g": 1,
|
||||
"r": 1
|
||||
},
|
||||
"CustomImage": {
|
||||
"CustomTile": {
|
||||
"Stackable": false,
|
||||
"Stretch": true,
|
||||
"Thickness": 0.1,
|
||||
"Type": 3
|
||||
},
|
||||
"ImageScalar": 1,
|
||||
"ImageSecondaryURL": "",
|
||||
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/2115061845796985108/F0ADB7094641DA966FFA3AF0CC6987D33D2D9591/",
|
||||
"WidthScale": 0
|
||||
},
|
||||
"Description": "Use the buttons to show / hide a playmat.",
|
||||
"DragSelectable": true,
|
||||
"GMNotes": "",
|
||||
"GUID": "a758b2",
|
||||
"Grid": true,
|
||||
"GridProjection": false,
|
||||
"Hands": false,
|
||||
"HideWhenFaceDown": false,
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "require(\"accessories/PlayermatHider\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Custom_Tile",
|
||||
"Nickname": "PlayermatHider",
|
||||
"Snap": true,
|
||||
"Sticky": true,
|
||||
"Tags": [
|
||||
"CleanUpHelper_ignore"
|
||||
],
|
||||
"Tooltip": true,
|
||||
"Transform": {
|
||||
"posX": 0,
|
||||
"posY": 2,
|
||||
"posZ": 0,
|
||||
"rotX": 0,
|
||||
"rotY": 270,
|
||||
"rotZ": 0,
|
||||
"scaleX": 5,
|
||||
"scaleY": 1,
|
||||
"scaleZ": 5
|
||||
},
|
||||
"Value": 0,
|
||||
"XmlUI": "\u003cInclude src=\"accessories/PlayermatHider.xml\"/\u003e"
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||
local playmatApi = require("playermat/PlaymatApi")
|
||||
|
||||
function onClick_hide(player, matColor)
|
||||
local objects = guidReferenceApi.getObjectsByOwner(matColor)
|
||||
if not objects.Playermat then return end
|
||||
|
||||
player.showConfirmDialog("Really remove this playmat and related objects? This can't be reversed.",
|
||||
function()
|
||||
-- remove action tokens
|
||||
local actionTokens = playmatApi.searchAroundPlaymat(matColor, "isActionToken")
|
||||
for _, obj in ipairs(actionTokens) do
|
||||
obj.destruct()
|
||||
end
|
||||
|
||||
-- remove mat owned objects
|
||||
for _, obj in pairs(objects) do
|
||||
obj.destruct()
|
||||
end
|
||||
end)
|
||||
end
|
@ -3,7 +3,6 @@ require("playercards/PlayerCardSpawner")
|
||||
|
||||
local allCardsBagApi = require("playercards/AllCardsBagApi")
|
||||
local arkhamDb = require("arkhamdb/ArkhamDb")
|
||||
local playAreaApi = require("core/PlayAreaApi")
|
||||
local playmatApi = require("playermat/PlaymatApi")
|
||||
local zones = require("playermat/Zones")
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||
local playmatApi = require("playermat/PlaymatApi")
|
||||
|
||||
local ZONE, TRASH, loopID
|
||||
local ZONE, TRASH
|
||||
local doomURL = "https://i.imgur.com/EoL7yaZ.png"
|
||||
local IGNORE_TAG = "DoomCounter_ignore"
|
||||
local TOTAL_PLAY_AREA = {
|
||||
@ -32,7 +32,7 @@ function onLoad()
|
||||
|
||||
TRASH = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
|
||||
ZONE = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone")
|
||||
loopID = Wait.time(updateCounter, 2, -1)
|
||||
Wait.time(updateCounter, 2, -1)
|
||||
end
|
||||
|
||||
-- main function
|
||||
|
@ -37,7 +37,6 @@ local chaosTokensLastMatGUID = nil
|
||||
local tokenDrawingStats = { ["Overall"] = {} }
|
||||
|
||||
local bagSearchers = {}
|
||||
local MAT_COLORS = { "White", "Orange", "Green", "Red" }
|
||||
local hideTitleSplashWaitFunctionId = nil
|
||||
|
||||
-- online functionality related variables
|
||||
|
@ -99,10 +99,7 @@ local starterDeckMode = STARTER_DECK_MODE_CARDS_ONLY
|
||||
local helpVisibleToPlayers = { }
|
||||
|
||||
function onSave()
|
||||
local saveState = {
|
||||
spawnBagState = spawnBag.getStateForSave(),
|
||||
}
|
||||
return JSON.encode(saveState)
|
||||
return JSON.encode({ spawnBagState = spawnBag.getStateForSave() })
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
|
@ -10,11 +10,11 @@ Spawner = { }
|
||||
-- investigator, standard, and mini, spawning them in that order with larger cards on bottom. If
|
||||
-- there are different types, the provided callback will be called once for each type as it spawns
|
||||
-- either a card or deck.
|
||||
-- @param cardList: A list of Player Card data structures (data/metadata)
|
||||
-- @param pos Position table where the cards should be spawned (global)
|
||||
-- @param rot Rotation table for the orientation of the spawned cards (global)
|
||||
-- @param sort Boolean, true if this list of cards should be sorted before spawning
|
||||
-- @param callback Function, callback to be called after the card/deck spawns.
|
||||
---@param cardList table A list of Player Card data structures (data/metadata)
|
||||
---@param pos tts__Vector table where the cards should be spawned (global)
|
||||
---@param rot tts__Vector table for the orientation of the spawned cards (global)
|
||||
---@param sort boolean True if this list of cards should be sorted before spawning
|
||||
---@param callback? function Callback to be called after the card/deck spawns.
|
||||
Spawner.spawnCards = function(cardList, pos, rot, sort, callback)
|
||||
if (sort) then
|
||||
table.sort(cardList, Spawner.cardComparator)
|
||||
@ -80,29 +80,30 @@ end
|
||||
---@param cardList table A list of Player Card data structures (data/metadata)
|
||||
---@param pos table Position where the cards should be spawned (global)
|
||||
---@param rot table Rotation for the orientation of the spawned cards (global)
|
||||
---@param callback function callback to be called after the card/deck spawns.
|
||||
---@param callback? function callback to be called after the card/deck spawns.
|
||||
Spawner.spawn = function(cardList, pos, rot, callback)
|
||||
if (#cardList == 0) then
|
||||
return
|
||||
end
|
||||
if #cardList == 0 then return end
|
||||
|
||||
-- Spawn a single card directly
|
||||
if (#cardList == 1) then
|
||||
spawnObjectData({
|
||||
data = cardList[1].data,
|
||||
position = pos,
|
||||
rotation = rot,
|
||||
callback_function = callback,
|
||||
callback_function = callback
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
-- For multiple cards, construct a deck and spawn that
|
||||
local deck = Spawner.buildDeckDataTemplate()
|
||||
|
||||
-- Decks won't inherently scale to the cards in them. The card list being spawned should be all
|
||||
-- the same type/size by this point, so use the first card to set the size
|
||||
deck.Transform = {
|
||||
scaleX = cardList[1].data.Transform.scaleX,
|
||||
scaleY = 1,
|
||||
scaleZ = cardList[1].data.Transform.scaleZ,
|
||||
scaleZ = cardList[1].data.Transform.scaleZ
|
||||
}
|
||||
local sidewaysDeck = true
|
||||
for _, spawnCard in ipairs(cardList) do
|
||||
@ -110,15 +111,17 @@ Spawner.spawn = function(cardList, pos, rot, callback)
|
||||
-- set sidewaysDeck to false if any card is not a sideways card
|
||||
sidewaysDeck = (sidewaysDeck and spawnCard.data.SidewaysCard)
|
||||
end
|
||||
|
||||
-- set the alt view angle for sideway decks
|
||||
if sidewaysDeck then
|
||||
deck.AltLookAngle = { x = 0, y = 180, z = 90 }
|
||||
end
|
||||
|
||||
spawnObjectData({
|
||||
data = deck,
|
||||
position = pos,
|
||||
rotation = rot,
|
||||
callback_function = callback,
|
||||
callback_function = callback
|
||||
})
|
||||
end
|
||||
|
||||
@ -187,9 +190,9 @@ Spawner.buildDeckDataTemplate = function()
|
||||
end
|
||||
|
||||
-- Returns the first ID which does not exist in the given table, starting at startId and increasing
|
||||
-- @param objectTable Table keyed by strings which are numbers
|
||||
-- @param startId First possible ID.
|
||||
-- @return String ID >= startId
|
||||
---@param objectTable table keyed by strings which are numbers
|
||||
---@param startId string possible ID.
|
||||
---@return string id >= startId
|
||||
Spawner.findNextAvailableId = function(objectTable, startId)
|
||||
local id = startId
|
||||
while (objectTable[id] ~= nil) do
|
||||
|
@ -78,8 +78,7 @@ do
|
||||
}
|
||||
end
|
||||
|
||||
-- Places the given spawnSpec on the table. See SpawnBag.ttslua header for spawnSpec table data and
|
||||
-- examples
|
||||
-- Places the given spawnSpec on the table. See comment at the start of the file for spawnSpec table data and examples
|
||||
SpawnBag.spawn = function(spawnSpec)
|
||||
-- Limit to one placement at a time
|
||||
if (placedSpecs[spawnSpec.name]) then
|
||||
|
@ -300,14 +300,12 @@ function doUpkeep(_, clickedByColor, isRightClick)
|
||||
|
||||
-- flip investigator mini-card and summoned servitor mini-card
|
||||
-- (all characters allowed to account for custom IDs - e.g. 'Z0000' for TTS Zoop generated IDs)
|
||||
if activeInvestigatorId ~= nil then
|
||||
local miniId = string.match(activeInvestigatorId, ".....") .. "-m"
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
if obj.type == "Card" and obj.is_face_down then
|
||||
local notes = JSON.decode(obj.getGMNotes())
|
||||
if notes ~= nil and notes.type == "Minicard" and (notes.id == miniId or notes.id == "09080-m") then
|
||||
obj.flip()
|
||||
end
|
||||
local miniId = string.match(activeInvestigatorId, ".....") .. "-m"
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
if obj.type == "Card" and obj.is_face_down then
|
||||
local notes = JSON.decode(obj.getGMNotes())
|
||||
if notes ~= nil and notes.type == "Minicard" and (notes.id == miniId or notes.id == "09080-m") then
|
||||
obj.flip()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user