Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

TokenMod and bar values

1524689607

Edited 1524689685
MSG
Pro
Sheet Author
I'm trying to use TokenMod to place a value in Bar3 that updates as the character uses a torch.  I'm running 1st Ed AD&D character sheet.  I've got a macro that calls the Torch script when they light a torch, ChatSetAttr to deduct a torch from the character's inventory and another script that calls TokenMod (after a delay) when the torch "goes out". I've tried using:  !token-mod --set bar3_value|@(selected|repeating_equipment_$0_quantity) as torches are in that repeating section slot, but it obediently puts the whole string in there rather than the value. I then tried: !token-mod --set bar3_value|[[@(selected|repeating_equipment_$0_quantity)]] and end up getting a syntax error. Yes - I do have a token selected before running the command and I have insured that there is a value in that field.  Is it possible to do this?  I want to use Bar3 to let the characters see how many torches they have left without having to pull up their character sheet every time.  The macro (currently) to take care of the other stuff is: !torch 80 72 yes --360 @{selected|token_id} !setattr --silent --sel --repeating_equipment_$0_quantity|[[@{selected|repeating_equipment_$0_quantity} -1]] !delay [[10*60*1000]] !token-mod --set light_radius|20 light_dimradius|18 light_otherplayers|yes light_angle|360 I'd like to be able to add in (after Line 1 or Line 2) where the Bar3 Value gets updated with how many torches they have left.  I've probably got the formatting wrong (hence the syntax error on the 2nd one) or it isn't possible - that would be my guess as to why it's not working as I hoped. Thanks!
1524690132
The Aaron
Pro
API Scripter
Looks like you have ( instead of { in:  !token-mod --set bar3_value|@(selected|repeating_equipment_$0_quantity) Try:  !token-mod --set bar3_value|@{selected|repeating_equipment_$0_quantity}
1524690334
MSG
Pro
Sheet Author
Thanks!  That worked. These old eyes have a hard time with ( and { - they look the same to me unless I get up close.
1524690539
The Aaron
Pro
API Scripter
No worries.  =D
1524690811
MSG
Pro
Sheet Author
It works, but - even after I put it after line 2, which deducts from inventory - the bar value shows 1 higher than what's actually in inventory.
1524691452
The Aaron
Pro
API Scripter
That's because of the order that things happen.  All of the attribute references are expanded before the commands are sent to the API, so you end up with something like this going to the API: !torch 80 72 yes --360 -Jk1sd12323s !setattr --silent --sel --repeating_equipment_$0_quantity|[[7 -1]] !token-mod --set bar3_value|7 !delay [[10*60*1000]] !token-mod --set light_radius|20 light_dimradius|18 light_otherplayers|yes light_angle|360 The answer is to send the deduction like you to with !setattr: !token-mod --set bar3_value|[[@{selected|repeating_equipment_$0_quantity}-1]]
1524691686
MSG
Pro
Sheet Author
Tinkering around, I did figure that out.  :) However, I seem to be having a problem with the Delay script on first use.  It seems to happen after I've adjusted the number of Torches in inventory (so I don't run it below 0 while testing).  The Delay script after doing this seems to only last for about 5-10 seconds, rather than the 10 minutes.  Here's the macro I've got: !torch 80 72 yes --360 @{selected|token_id} !setattr --silent --sel --repeating_equipment_$0_quantity|[[@{selected|repeating_equipment_$0_quantity} -1]] !token-mod --set bar3_value|[[@{selected|repeating_equipment_$0_quantity}-1]] !delay [[10*60*1000]] !token-mod --set light_radius|20 light_dimradius|18 light_otherplayers|yes light_angle|360 The count in the Bar3 is now correct, but first use after manual inventory adjustment (like they've bought more torches) makes the first delay very short.
1524691983
The Aaron
Pro
API Scripter
hmm. that is strange.  I'm trying to think of how that could happen.  One thing might be if you started one earlier and it just now hit.  Lighting a new torch isn't going to cancel an old delay.
1524692126
MSG
Pro
Sheet Author
Maybe my manual TorchOff macro needs to be able to cancel any delays?  Is that possible?
1524692375
The Aaron
Pro
API Scripter
It is possible. Have to think about what the best way to trigger that is.  Probably add a label to the delay that is associated with the selected tokens, if the same delay label is specified for the tokens, it replaces the existing one...  might have to tie it to character to be certain it works out right...
1524692605
MSG
Pro
Sheet Author
If it ties to the selected token, and overwrites the previous delay on that token, then maybe a !delay 0 ... on my TorchOff macro could use that to cancel out the old delay?
1524692860
The Aaron
Pro
API Scripter
Yeah, something along those lines.
1524693340
MSG
Pro
Sheet Author
Well, you did ask for feedback on that Delay script.  ;)
1524693560
The Aaron
Pro
API Scripter
=D
1524732813
MSG
Pro
Sheet Author
The Aaron, If you do decide to do an update to the Delay script, I'm following this topic so I'll get notified.  If you don't want to post it here (if you do an update), you can always toss it in that PM we had going recently.  :)