From e0484d190ab721a3d917799555b4f912f07438c4 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 16 Mar 2023 10:46:53 +0100 Subject: [PATCH] fix for replenish script to allow overcharging --- src/playermat/Playmat.ttslua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index fbc72e82..fbd6c9db 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -500,9 +500,18 @@ function replenishTokens(card, count, replenish) end end + -- this is the theoretical new amount of uses (to be checked below) local newCount = foundTokens + replenish - if newCount > count then newCount = count end + + -- if there are already more uses than the replenish amount, keep them + if foundTokens > count then + newCount = foundTokens + -- only replenish up until the replenish amount + elseif newCount > count then + newCount = count + end + -- update the clickable counter or spawn a group of tokens if clickableResourceCounter then clickableResourceCounter.call("updateVal", newCount) else