updated code to update onHover
This commit is contained in:
parent
52c19cd6dd
commit
2f21b2f2cf
@ -22,7 +22,7 @@
|
||||
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/1704036721123215146/E44A3B99EACF310E49E94977151A03C9A3DC7F17/",
|
||||
"WidthScale": 0
|
||||
},
|
||||
"Description": "Displays the hand size (total or by title for \"Dream Enhancing Serum\" - hover over it to temporarily to see the regular count).\n\nWill detect if DES is present during each Upkeep.\n\nAllows you to randomly discard a card from your hand.",
|
||||
"Description": "Displays the hand size (total or by title for \"Dream Enhancing Serum\" - hover over it to see the regular count).\n\nAllows you to randomly discard a card from your hand.",
|
||||
"DragSelectable": true,
|
||||
"GMNotes": "",
|
||||
"GUID": "450688",
|
||||
|
@ -1,7 +1,7 @@
|
||||
local playmatApi = require("playermat/PlaymatApi")
|
||||
|
||||
-- forward declaration of variables that are used across functions
|
||||
local matColor, handColor, loopId, hovering
|
||||
local matColor, handColor, hovering
|
||||
|
||||
function onLoad()
|
||||
local buttonParamaters = {}
|
||||
@ -10,7 +10,7 @@ function onLoad()
|
||||
-- index 0: button as hand size label
|
||||
buttonParamaters.hover_color = "White"
|
||||
buttonParamaters.click_function = "none"
|
||||
buttonParamaters.position = { 0, 0.11, -0.4 }
|
||||
buttonParamaters.position = Vector(0, 0.11, -0.4)
|
||||
buttonParamaters.height = 0
|
||||
buttonParamaters.width = 0
|
||||
buttonParamaters.font_size = 500
|
||||
@ -19,17 +19,14 @@ function onLoad()
|
||||
|
||||
-- index 1: button to toggle "des"
|
||||
buttonParamaters.label = "DES: ✗"
|
||||
buttonParamaters.click_function = "none"
|
||||
buttonParamaters.position = { 0, 0.11, 0.25 }
|
||||
buttonParamaters.height = 0
|
||||
buttonParamaters.width = 0
|
||||
buttonParamaters.position.z = 0.25
|
||||
buttonParamaters.font_size = 120
|
||||
self.createButton(buttonParamaters)
|
||||
|
||||
-- index 2: button to discard a card
|
||||
buttonParamaters.label = "discard random card"
|
||||
buttonParamaters.label = "Discard Random Card"
|
||||
buttonParamaters.click_function = "discardRandom"
|
||||
buttonParamaters.position = { 0, 0.11, 0.7 }
|
||||
buttonParamaters.position.z = 0.7
|
||||
buttonParamaters.height = 175
|
||||
buttonParamaters.width = 900
|
||||
buttonParamaters.font_size = 90
|
||||
@ -51,11 +48,11 @@ function onObjectHover(hoverColor, object)
|
||||
|
||||
if object == self then
|
||||
hovering = true
|
||||
playmatApi.checkForDES(matColor)
|
||||
updateValue()
|
||||
else
|
||||
hovering = false
|
||||
end
|
||||
|
||||
updateValue()
|
||||
end
|
||||
|
||||
-- updates the matcolor and handcolor variable
|
||||
@ -75,10 +72,10 @@ function updateValue()
|
||||
-- if there is still no handzone, then end here
|
||||
if Player[handColor].getHandCount() == 0 then return end
|
||||
|
||||
-- get state of "Dream-Enhancing Serum" from playermat and update button label
|
||||
-- get state of "Dream-Enhancing Serum" from playermat
|
||||
local hasDES = playmatApi.hasDES(matColor)
|
||||
|
||||
-- get opposite value if currently hovered
|
||||
-- default to regular count if hovered
|
||||
if hovering then
|
||||
hasDES = false
|
||||
end
|
||||
|
@ -295,8 +295,8 @@ function doUpkeep(_, clickedByColor, isRightClick)
|
||||
updateMessageColor(clickedByColor)
|
||||
|
||||
-- unexhaust cards in play zone, flip action tokens and find Forced Learning / Dream-Enhancing Serum
|
||||
checkForDES()
|
||||
local forcedLearning = false
|
||||
hasDES = false
|
||||
local rot = self.getRotation()
|
||||
for _, obj in ipairs(searchAroundSelf()) do
|
||||
if obj.getDescription() == "Action Token" and obj.is_face_down then
|
||||
@ -326,8 +326,6 @@ function doUpkeep(_, clickedByColor, isRightClick)
|
||||
-- detect Forced Learning to handle card drawing accordingly
|
||||
if cardMetadata.id == "08031" then
|
||||
forcedLearning = true
|
||||
elseif cardMetadata.id == "06159" then
|
||||
hasDES = true
|
||||
end
|
||||
|
||||
-- maybe replenish uses on certain cards
|
||||
@ -541,6 +539,23 @@ function doDiscardOne()
|
||||
end
|
||||
end
|
||||
|
||||
-- checks if DES is present
|
||||
function checkForDES()
|
||||
hasDES = false
|
||||
for _, obj in ipairs(searchAroundSelf()) do
|
||||
if obj.type == "Card" then
|
||||
local cardMetadata = JSON.decode(obj.getGMNotes()) or {}
|
||||
|
||||
-- position is used to exclude deck / discard
|
||||
local cardPos = self.positionToLocal(obj.getPosition())
|
||||
if cardMetadata.id == "06159" and cardPos.x < 1 then
|
||||
hasDES = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------
|
||||
-- slot symbol displaying
|
||||
---------------------------------------------------------
|
||||
|
@ -47,8 +47,17 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- Instructs a playmat to check for DES
|
||||
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
|
||||
PlaymatApi.checkForDES = function(matColor)
|
||||
for _, mat in pairs(getMatForColor(matColor)) do
|
||||
mat.call("checkForDES")
|
||||
end
|
||||
end
|
||||
|
||||
-- Returns if there is the card "Dream-Enhancing Serum" on the requested playmat
|
||||
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||
---@return boolean: whether DES is present on the playmat
|
||||
PlaymatApi.hasDES = function(matColor)
|
||||
for _, mat in pairs(getMatForColor(matColor)) do
|
||||
return mat.getVar("hasDES")
|
||||
|
Loading…
Reference in New Issue
Block a user