From abbc8d5ff27765aadee5c2351dc4891d1e90fb09 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 8 Jul 2024 09:29:15 +0200 Subject: [PATCH 1/2] fixed hand helper being loaded first --- src/accessories/HandHelper.ttslua | 15 +++++++++++---- src/playermat/Playermat.ttslua | 10 ++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/accessories/HandHelper.ttslua b/src/accessories/HandHelper.ttslua index 8728388e..d67e73bf 100644 --- a/src/accessories/HandHelper.ttslua +++ b/src/accessories/HandHelper.ttslua @@ -9,6 +9,7 @@ function onLoad() -- index 0: button as hand size label buttonParamaters.hover_color = "White" + buttonParamaters.label = 0 buttonParamaters.click_function = "none" buttonParamaters.position = Vector(0, 0.11, -0.4) buttonParamaters.height = 0 @@ -33,11 +34,14 @@ function onLoad() buttonParamaters.font_color = "Black" self.createButton(buttonParamaters) - updateColors() + -- make sure this part executes after the playermats are loaded + Wait.time(function() + updateColors() - -- start loop to update card count - playermatApi.checkForDES(matColor) - Wait.time(updateValue, 1, -1) + -- start loop to update card count + playermatApi.checkForDES(matColor) + Wait.time(updateValue, 1, -1) + end, 1) end -- updates colors when object is dropped somewhere @@ -70,6 +74,9 @@ function updateValue() updateColors() end + -- if one of the colors is undefined, then end here + if matColor == nil or handColor == nil then return end + -- if there is still no handzone, then end here if Player[handColor].getHandCount() == 0 then return end diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index a58aeeb8..d6429e9d 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -554,13 +554,11 @@ function doDiscardOne() else local choices = {} for i = 1, #hand do - local notes = JSON.decode(hand[i].getGMNotes()) - if notes ~= nil then - if notes.hidden ~= true then - table.insert(choices, i) - end - else + local md = JSON.decode(hand[i].getGMNotes()) + if md ~= nil and (not md.weakness and not md.hidden and md.type ~= "Enemy") then table.insert(choices, i) + else + broadcastToColor(hand[i].getName() .. " is missing metadata and won't be discarded.", messageColor, "Orange") end end From 181caf025d1f87d626d7b988055146ca31c7c9af Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 8 Jul 2024 13:11:45 +0200 Subject: [PATCH 2/2] updated condition --- src/playermat/Playermat.ttslua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index d6429e9d..4e97e3ec 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -557,7 +557,7 @@ function doDiscardOne() local md = JSON.decode(hand[i].getGMNotes()) if md ~= nil and (not md.weakness and not md.hidden and md.type ~= "Enemy") then table.insert(choices, i) - else + elseif md == nil then broadcastToColor(hand[i].getName() .. " is missing metadata and won't be discarded.", messageColor, "Orange") end end