more dynamic references
This commit is contained in:
parent
2d85f913b1
commit
18c06b4691
@ -36,6 +36,7 @@
|
||||
"LuaScript": "require(\"core/MasterClueCounter\")",
|
||||
"LuaScriptState": "false",
|
||||
"MeasureMovement": false,
|
||||
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"MasterClueCounter\"}",
|
||||
"Name": "Custom_Token",
|
||||
"Nickname": "Master Clue Counter",
|
||||
"Snap": true,
|
||||
|
@ -36,6 +36,7 @@
|
||||
"LuaScript": "require(\"core/DoomInPlayCounter\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"DoomInPlayCounter\"}",
|
||||
"Name": "Custom_Token",
|
||||
"Nickname": "Other Doom in Play",
|
||||
"Snap": true,
|
||||
|
@ -64,8 +64,7 @@ function startReset()
|
||||
if options.Agenda then
|
||||
updateVal(0)
|
||||
end
|
||||
-- call the "Doom-in-Play"-counter
|
||||
local DoomInPlayCounter = getObjectFromGUID("652ff3")
|
||||
local DoomInPlayCounter = getObjectFromMemo({matColor = "Mythos", type = "DoomInPlayCounter"})
|
||||
if DoomInPlayCounter then
|
||||
DoomInPlayCounter.call("removeDoom", options)
|
||||
end
|
||||
|
@ -41,7 +41,7 @@ end
|
||||
|
||||
-- adds 1 doom to the agenda
|
||||
function addDoomToAgenda()
|
||||
getObjectFromGUID("85c4c6").call("addVal", 1)
|
||||
getObjectFromMemo({matColor = "Mythos", type = "DoomCounter"}).call("addVal", 1)
|
||||
end
|
||||
|
||||
-- moves the hovered card to the victory display
|
||||
|
@ -922,7 +922,7 @@ function applyOptionPanelChange(id, state)
|
||||
optionPanel[id] = state
|
||||
|
||||
-- update master clue counter
|
||||
getObjectFromGUID("4a3aa4").setVar("useClickableCounters", state)
|
||||
getObjectFromMemo({matColor = "Mythos", type = "MasterClueCounter"}).setVar("useClickableCounters", state)
|
||||
|
||||
-- option: Play area snap tags
|
||||
elseif id == "playAreaSnapTags" then
|
||||
|
@ -1,26 +1,15 @@
|
||||
local spawnedCardGuids = { }
|
||||
local spawnedCardGuids = {}
|
||||
|
||||
local HAND_ZONES = { }
|
||||
HAND_ZONES["a70eee"] = true -- White
|
||||
HAND_ZONES["0285cc"] = true -- Green
|
||||
HAND_ZONES["5fe087"] = true -- Orange
|
||||
HAND_ZONES["be2f17"] = true -- Red
|
||||
function onSave() return JSON.encode({ cards = spawnedCardGuids }) end
|
||||
|
||||
function onLoad(saveState)
|
||||
if saveState ~= nil then
|
||||
local saveTable = JSON.decode(saveState) or { }
|
||||
spawnedCardGuids = saveTable.cards or { }
|
||||
local saveTable = JSON.decode(saveState) or {}
|
||||
spawnedCardGuids = saveTable.cards or {}
|
||||
end
|
||||
|
||||
createResetMenuItems()
|
||||
end
|
||||
|
||||
function onSave()
|
||||
return JSON.encode({
|
||||
cards = spawnedCardGuids
|
||||
})
|
||||
end
|
||||
|
||||
function createResetMenuItems()
|
||||
self.addContextMenuItem("Reset All", resetAll)
|
||||
self.addContextMenuItem("Reset Locations", resetAllLocations)
|
||||
@ -39,14 +28,20 @@ function resetTokensSpawned(cardGuid)
|
||||
spawnedCardGuids[cardGuid] = nil
|
||||
end
|
||||
|
||||
function resetAllAssetAndEvents()
|
||||
local resetList = { }
|
||||
function resetAll() spawnedCardGuids = {} end
|
||||
|
||||
function resetAllLocations() resetSpecificTypes("Location") end
|
||||
|
||||
function resetAllAssetAndEvents() resetSpecificTypes("Asset", "Event") end
|
||||
|
||||
function resetSpecificTypes(type1, type2)
|
||||
local resetList = {}
|
||||
for cardGuid, _ in pairs(spawnedCardGuids) do
|
||||
local card = getObjectFromGUID(cardGuid)
|
||||
if card ~= nil then
|
||||
local cardMetadata = JSON.decode(card.getGMNotes()) or { }
|
||||
local cardMetadata = JSON.decode(card.getGMNotes()) or {}
|
||||
-- Check this by type rather than the PlayerCard tag so we don't reset weaknesses
|
||||
if cardMetadata.type == "Asset" or cardMetadata.type == "Event" then
|
||||
if cardMetadata.type == type1 or cardMetadata.type == type2 then
|
||||
resetList[cardGuid] = true
|
||||
end
|
||||
end
|
||||
@ -56,30 +51,21 @@ function resetAllAssetAndEvents()
|
||||
end
|
||||
end
|
||||
|
||||
function resetAllLocations()
|
||||
local resetList = { }
|
||||
for cardGuid, _ in pairs(spawnedCardGuids) do
|
||||
local card = getObjectFromGUID(cardGuid)
|
||||
if card ~= nil then
|
||||
local cardMetadata = JSON.decode(card.getGMNotes()) or { }
|
||||
-- Check this by type rather than the PlayerCard tag so we don't reset weaknesses
|
||||
if cardMetadata.type == "Location" then
|
||||
resetList[cardGuid] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
for cardGuid, _ in pairs(resetList) do
|
||||
spawnedCardGuids[cardGuid] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function resetAll()
|
||||
spawnedCardGuids = { }
|
||||
end
|
||||
|
||||
-- Listener to reset card token spawns when they enter a hand.
|
||||
function onObjectEnterZone(zone, enterObject)
|
||||
if HAND_ZONES[zone.getGUID()] then
|
||||
if checkMemo(zone) then
|
||||
resetTokensSpawned(enterObject.getGUID())
|
||||
end
|
||||
end
|
||||
|
||||
-- checks if the object is owned by a playermat
|
||||
function checkMemo(obj)
|
||||
local memo = obj.getMemo()
|
||||
if memo then
|
||||
local decoded = JSON.decode(memo) or {}
|
||||
if decoded.matColor ~= "Mythos" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
@ -20,14 +20,9 @@
|
||||
-- SetAside5: Hunch Deck for Joe Diamond
|
||||
-- SetAside6: currently unused
|
||||
do
|
||||
local playmatApi = require("playermat/PlaymatApi")
|
||||
local Zones = { }
|
||||
|
||||
local playerMatGuids = {}
|
||||
playerMatGuids["Red"] = "0840d5"
|
||||
playerMatGuids["Orange"] = "bd0ff4"
|
||||
playerMatGuids["White"] = "8b081b"
|
||||
playerMatGuids["Green"] = "383d8b"
|
||||
|
||||
local commonZones = {}
|
||||
commonZones["Investigator"] = { -1.17702, 0, 0.00209 }
|
||||
commonZones["Deck"] = { -1.822724, 0, -0.02940192 }
|
||||
@ -119,7 +114,7 @@ do
|
||||
and playerColor ~= "Green") then
|
||||
return nil
|
||||
end
|
||||
return getObjectFromGUID(playerMatGuids[playerColor]).positionToWorld(zoneData[playerColor][zoneName])
|
||||
return playmatApi.transformLocalPosition(zoneData[playerColor][zoneName], playerColor)
|
||||
end
|
||||
|
||||
-- Return the global rotation for a card on the given player mat, based on its metadata.
|
||||
@ -129,13 +124,11 @@ do
|
||||
-- Y rotation to orient the card on the given player mat as well as a
|
||||
-- Z rotation to place the card face up or face down.
|
||||
Zones.getDefaultCardRotation = function(playerColor, zone)
|
||||
local deckRotation = getObjectFromGUID(playerMatGuids[playerColor]).getRotation()
|
||||
|
||||
local cardRotation = playmatApi.returnRotation(playerColor)
|
||||
if zone == "Deck" then
|
||||
deckRotation = deckRotation + Vector(0, 0, 180)
|
||||
cardRotation = cardRotation + Vector(0, 0, 180)
|
||||
end
|
||||
|
||||
return deckRotation
|
||||
return cardRotation
|
||||
end
|
||||
|
||||
return Zones
|
||||
|
Loading…
x
Reference in New Issue
Block a user