initial build

This commit is contained in:
Chr1Z93 2023-01-27 19:22:29 +01:00
parent 7ca3f91b95
commit b40c6e6d9e
4 changed files with 190 additions and 22 deletions

View File

@ -3,7 +3,6 @@
"ComponentTags_path": "ComponentTags.json", "ComponentTags_path": "ComponentTags.json",
"CustomUIAssets_path": "CustomUIAssets.json", "CustomUIAssets_path": "CustomUIAssets.json",
"DecalPallet_path": "DecalPallet.json", "DecalPallet_path": "DecalPallet.json",
"Decals_path": "Decals.json",
"GameComplexity": "", "GameComplexity": "",
"GameMode": "Arkham Horror LCG - Super Complete Edition", "GameMode": "Arkham Horror LCG - Super Complete Edition",
"GameType": "", "GameType": "",
@ -190,7 +189,8 @@
"Decoration-Ammo.0a3b03", "Decoration-Ammo.0a3b03",
"Decoration-Ammo.b43845", "Decoration-Ammo.b43845",
"Decoration-Ammo.d35ee9", "Decoration-Ammo.d35ee9",
"ArkhamSCE300-1272023-Page1.f873a8" "ArkhamSCE300-1272023-Page1.f873a8",
"VictoryDisplay.6ccd6d"
], ],
"PlayArea": 1, "PlayArea": 1,
"PlayerCounts": [ "PlayerCounts": [

View File

@ -1,20 +0,0 @@
[
{
"CustomDecal": {
"ImageURL": "https://i.imgur.com/saWedQ0.png",
"Name": "Victory Display",
"Size": 15
},
"Transform": {
"posX": -1.76003075,
"posY": 1.491499,
"posZ": 28.6174583,
"rotX": 90,
"rotY": 89.6667938,
"rotZ": 0,
"scaleX": 15,
"scaleY": 15,
"scaleZ": 15
}
}
]

View File

@ -0,0 +1,57 @@
{
"AltLookAngle": {
"x": 0,
"y": 0,
"z": 0
},
"Autoraise": true,
"ColorDiffuse": {
"b": 1,
"g": 1,
"r": 1
},
"CustomImage": {
"CustomToken": {
"MergeDistancePixels": 15,
"Stackable": false,
"StandUp": false,
"Thickness": 0.1
},
"ImageScalar": 1,
"ImageSecondaryURL": "",
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/5118935530961118802/2A3E0C502886C4C4B98F5A0B03817ABC9DFE3D96/",
"WidthScale": 0
},
"Description": "Automatically counts the earned VP from cards in the victory display and locations in the play area without clues on them.",
"DragSelectable": true,
"GMNotes": "",
"GUID": "6ccd6d",
"Grid": true,
"GridProjection": false,
"Hands": false,
"HideWhenFaceDown": false,
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "require(\"core/VictoryDisplay\")",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Custom_Token",
"Nickname": "Victory Display",
"Snap": false,
"Sticky": true,
"Tooltip": true,
"Transform": {
"posX": -1.5,
"posY": 1.531,
"posZ": 30,
"rotX": 0,
"rotY": 270,
"rotZ": 0,
"scaleX": 4.5,
"scaleY": 1,
"scaleZ": 4.5
},
"Value": 0,
"XmlUI": ""
}

View File

@ -0,0 +1,131 @@
function onLoad()
local buttonParameters = {}
buttonParameters.label = "0 (Display) + 0 (Play Area) = 0 VP"
buttonParameters.click_function = "none"
buttonParameters.function_owner = self
buttonParameters.position = { x = -0.5, y = 0.11, z = -0.8 }
buttonParameters.scale = { 0.15, 0.15, 0.15 }
buttonParameters.width = 0
buttonParameters.height = 0
buttonParameters.font_size = 600
buttonParameters.font_color = { 1, 1, 1 }
-- index 0: VP calculation
self.createButton(buttonParameters)
-- index 1: title
buttonParameters.position = { x = 0, y = 0.11, z = -1.15 }
buttonParameters.label = "Victory Display"
buttonParameters.font_size = 1000
self.createButton(buttonParameters)
-- index 2: refresh button
buttonParameters.position = { x = 1.65, y = 0.11, z = -0.8 }
buttonParameters.label = "Refresh!"
buttonParameters.click_function = "updateCount"
buttonParameters.width = 2400
buttonParameters.height = 800
buttonParameters.font_color = { 0, 0, 0 }
buttonParameters.font_size = 600
self.createButton(buttonParameters)
-- update the display label once
Wait.time(updateCount, 1)
end
-- automatically update when cards are dropped or removed
function onCollisionEnter() updateCount() end
function onCollisionExit() Wait.time(updateCount, 0.1) end
function updateCount()
local victoryPoints = {
display = 0,
playArea = 0
}
-- count cards in victory display
for _, v in ipairs(searchOnObj(self)) do
local obj = v.hit_object
local cardVP = 0
-- check metadata for VP
if obj.tag == "Card" then
cardVP = getCardVP(obj.is_face_down, JSON.decode(obj.getGMNotes()))
victoryPoints.display = victoryPoints.display + cardVP
-- handling for stacked cards
elseif obj.tag == "Deck" then
for _, deepObj in ipairs(obj.getObjects()) do
cardVP = getCardVP(true, JSON.decode(deepObj.gm_notes))
victoryPoints.display = victoryPoints.display + cardVP
end
end
end
-- count locations in playArea
local playArea = getObjectFromGUID("721ba2")
for _, v in ipairs(searchOnObj(playArea)) do
local obj = v.hit_object
local cardVP = 0
if obj.hasTag("Location") then
cardVP = getCardVP(obj.is_face_down, JSON.decode(obj.getGMNotes()))
if cardVP and not cardHasClues(obj) then
victoryPoints.playArea = victoryPoints.playArea + cardVP
end
end
end
self.editButton({
index = 0,
label = victoryPoints.display .. " (Display) + "
.. victoryPoints.playArea .. " (Play Area) = "
.. victoryPoints.display + victoryPoints.playArea .. " VP"
})
end
-- checks if a card has clues on it
function cardHasClues(card)
for _, v in ipairs(searchOnObj(card)) do
local obj = v.hit_object
if obj.tag == "Tile" then
local props = obj.getCustomObject()
if obj.is_face_down == false and
props.image == "http://cloud-3.steamusercontent.com/ugc/1758068501357164917/1D06F1DC4D6888B6F57124BD2AFE20D0B0DA15A8/" and
props.image_bottom == "https://i.imgur.com/EoL7yaZ.png" then
return true
end
end
end
return false
end
-- gets the VP count from the notes
function getCardVP(faceDown, notes)
local cardVP
if notes ~= nil then
-- enemy, treachery etc.
cardVP = tonumber(notes.victory)
-- location
if not cardVP then
if not faceDown then
cardVP = tonumber(notes.locationFront.victory)
else
cardVP = tonumber(notes.locationBack.victory)
end
end
end
return cardVP or 0
end
function searchOnObj(obj)
return Physics.cast({
direction = { 0, 1, 0 },
max_distance = 0.5,
type = 3,
size = obj.getBounds().size,
origin = obj.getPosition()
})
end