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

[Script Update] TokenMod -- An interface to adjusting properties of a token from a macro or the chat area.

Just tested it out - didn't change anything, unfortunately. 


Jarren K. said:

Try using an equals sign:

!token-mod {{
--set emits_bright|false 
--set emits_low|true
--set low_distance|=5

}}




July 04 (3 years ago)

Edited July 04 (3 years ago)


Margaret said:

Just tested it out - didn't change anything, unfortunately. 

Odd, it's working correctly for me with what you posted originally. Do you have any other scripts turned on? Which version of TokenMod do you have loaded? Are you using a macro button, or pasting that code directly into chat?


Maybe try this syntax (it shouldn't matter, but worth checking):

!token-mod {{
--set 
emits_bright|true
bright_distance|30
emits_low|true
low_distance|5
}}

Haha I'm glad it works somewhere - feels a little better than me just missing something super obvious in a simple bit of code! Right now I've got Aura/Tint HealthColors, Concentration, 5th Edition OGL, StatusInfo, Initiative Tracker Plus, Victor Math, MatrixMath, Path Math, Token Collisions, HTML Builder, Character Sheet Utils, It's a Trap!, and It's a Trap! D&D 5e Generic, as well as a wildshape script. I know that the code worked at some point but I don't have a clear idea as to when it actually stopped working, so I'm not sure if any of the scripts I added more recently would have had an impact.

Token Mod is set to the latest version, and I've been using macros but not posting to chat - just tested it out as a chat command and it does the same exact thing. Syntax unfortunately also didn't help.

Jarren K. said:


Margaret said:

Just tested it out - didn't change anything, unfortunately. 

Odd, it's working correctly for me with what you posted originally. Do you have any other scripts turned on? Which version of TokenMod do you have loaded? Are you using a macro button, or pasting that code directly into chat?


Maybe try this syntax (it shouldn't matter, but worth checking):

!token-mod {{
--set 
emits_bright|true
bright_distance|30
emits_low|true
low_distance|5
}}




July 06 (3 years ago)

My guess is an interaction with another script. 

I'd suggest simply reinstalling TokenMod in case somehow it got futzed and trying out the macro to see if it'll work for you, and if that doesn't clear it then disabling other scripts one by one.

I'd start with the wildshape script, as that probably sets vision based on the shape that is selected for the token.

July 06 (3 years ago)

Edited July 06 (3 years ago)

I'm playing around with a script to apply various modifications to a token based on their condition and/or status, and was wondering if there is a way to set or config the "bar1_max" value to half its current value. as a reference this is the script I've been playing with to try and change it; specifically the bolded line is one that I can't seem to figure out how to set/config the value. Any insights or help would be appreciated much.

  --:Exhaustion Level 4|
  --&Marker|exhaustion-lvl-4::4107419 --#rightsub|Condition --#Title|Exhaustion Level 4
  --+[sm width=25px]exhaustion-lvl-3[/sm]|You have now reached a 3rd level of exhaustion.
  --+[sm width=25px]disadvantage[/sm]|You have disadvantage on all ability checks
  --+| • Your speed is now halved
  --+[sm width=25px]disadvantage[/sm]|You have disadvantage on all attack rolls and saving throws
  --+|Your hit point maximum is now halved
  --@token-mod|_set bar1_max|
  --+|An effect that removes exhaustion reduces its level as specified in the effect’s description, with all exhaustion effects ending if a creature’s exhaustion level is reduced below 1.
  --+|Finishing a long rest reduces a creature’s exhaustion level by 1, provided that the creature has also ingested some food and drink. Also, being raised from the dead reduces a creature’s exhaustion level by 1
    --^MARK|


July 06 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

yes, you can use /2:

  --@token-mod|_set bar1_max|/2
July 06 (3 years ago)


The Aaron said:

yes, you can use /2:

  --@token-mod|_set bar1_max|/2


Thank you Aaron, I thought I had tried that, but I just copied and pasted your line and it worked. 

- Adept standing at the door of the Halls of Arcana watching and listening to the great script wizards.

July 07 (3 years ago)


The Aaron said:

Whoops!  Sorry about that.. in the middle of my Thursday night game and didn't notice the typo. That really should have said:

There isn't an API setting for the radius at which to start the dimming effect.


This stinks

July 07 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Actually... give me 10 minutes, I'm just writing the documentation on the ability to set the dimming radius... =D

July 07 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Update v0.8.70 - Added support for setting the Dimming radius for Night Vision (thanks Art )

Night Vision Effect

Night Vision Effect specifies how the region of night vision around a token looks. There are two effects that can be turned on: dimming and nocturnal. You can disable Night Vision Effects using offnone, or leave the field blank. Any other value is ignored.

Available Night Vision Effect Properties:
night_vision_effect

Enable the nocturnal Night Vision Effect on a token:

!token-mod --set night_vision_effect|nocturnal

Enable the dimming Night Vision Effect on a token, with dimming starting at 5ft from the token:

!token-mod --set night_vision_effect|dimming

Dimming can take an additional argument to set the distance from the token to begin dimming. The default is 5ft if not specified. Distances are provided by appending a another | character and adding a number followed by either a unit or a %:

!token-mod --set night_vision_effect|dimming|5ft
!token-mod --set night_vision_effect|dimming|1u

Using the % allows you to specify the distance as a percentage of the Night Vision Distance. Numbers less than 1 are treated as a decimal percentage. Both of the following are the same:

!token-mod --set night_vision_effect|dimming|20%
!token-mod --set night_vision_effect|dimming|0.2%

You can also use operators to make relative changes. Operators are +-*, and /

!token-mod --set night_vision_effect|dimming|+10%
!token-mod --set night_vision_effect|dimming|-5ft
!token-mod --set night_vision_effect|dimming|/2
!token-mod --set night_vision_effect|dimming|*10

Disable any Night Vision Effects on a token:

!token-mod --set night_vision_effect|off
!token-mod --set night_vision_effect|none
!token-mod --set night_vision_effect|


Should be available in the 1-click next week, or you can get it from my repo:  https://github.com/shdwjk/Roll20API/blob/master/TokenMod/TokenMod.js


July 07 (3 years ago)

Edited July 07 (3 years ago)


The Aaron said:

Actually... give me 10 minutes, I'm just writing the documentation on the ability to set the dimming radius... =D


CHEERS!!

P.S.  Works like a charm.  Thank you!

July 07 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

No problem. =D

July 08 (3 years ago)

@The Aaron... will this update cure the loss of nocturnal effect when !bumping the token?

July 08 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Is that a thing?  I'll try to duplicate that issue with Bump, but this change has nothing to do with that script. 

July 08 (3 years ago)

Yes... just to remind you...


****

Thanks as always to @The Aaron for his great work on Token Mod.

And for his great work on Bump.

I've recently converted to UDL... so far, so good... but I am running into one issue. I've got a simple Bump macro set for my characters who can turn invisible so that they can bump and unbump themselves at will. I've got Bump configured to Auto Push, Slave and Unslave, so the macro is nothing more than "!bump" ... easy. Worked fine under LDL, no issues.

Now with UDL, I've also got these tokens configured for UDL night vision at 60', using the nocturnal effect.

When the players bump themselves, or when I bump them, the night vision effect resets to "none." This leads to some very weird stuff happening... strange circles of darkness around other tokens... I'm gonna presume that's a possible UDL bug issue that will get worked out one day, but in the meantime, even if that stuff weren't happening, I'd want my bumped characters to still experience the nocturnal effect.

I tried to get around this by adding:

!token-mod --set night_vision_effect|nocturnal

to the bump macro, but it doesn't prevent the "effect = none" issue on bump. The nocturnal effect is restored, however, on unbump.

Any idea how to figure this out? Currently I'm manually adjusting each time they bump, but with a Cloak of Shadows monk who is visible/invisible depending on whether or not someone lights a torch nearby, it's gonna get tedious.

Thanks in advance for the assistance!

***

July 08 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Ah, right!  Thanks for the reminder, I'll try and take a look at that shortly.

July 09 (3 years ago)

Thank you, sir!

July 13 (3 years ago)

FYI I'm seeing a bug where vision and light settings are not correctly changing when using TokenMod. I've submitted a bug report but I figured I would let people know here as well in case they encounter the same thing.

API changes to a token vision settings do not work if the token is still set to emit light.

Using TokenMod, I have a token set to 5E darkvision as well as emitting light from a torch: 

!token-mod {{ --set has_bright_light_vision#on has_night_vision#no}}
!token-mod {{ --set has_bright_light_vision#on has_night_vision#on night_vision_distance#60 night_vision_effect|nocturnal}}
!token-mod {{ --set emits_bright_light#on emits_low_light#on bright_light_distance#15 low_light_distance#30}}

This all works just fine to turn the vision light setting on.  But if that character becomes blinded, I want it to continue to emit light for other characters but not be able to see:

!token-mod {{ --set has_bright_light_vision#no has_night_vision#no}}

No change takes place.  If I make the same change manually on the token page it works just fine to keep the light emitting but without the controlling player having vision from the token.

This is one specific use-case bug, but I've seen similar issues with other vision/light settings being changed through the API.

July 18 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Update 0.8.71 -- Fixed bug with setting night_vision_effect to off (Thanks Tom G. Battousai_CR)

New version is available in my github: https://github.com/shdwjk/Roll20API/blob/master/TokenMod/TokenMod.js

Or should be in the 1-click on Tuesday.

July 21 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Update 0.8.71 also includes support for lightColor:

!token-mod --set lightColor|#9900ff
July 23 (3 years ago)

Edited July 25 (3 years ago)

Hey! I put together a macro to change the light colour emitted by a token and thought that I would share it. Included are the basic colours and a collection of some others that I thought would be interesting. Here is a link to the website I used to find all the RGB Hex Values if you want to add a different colour: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value


!token-mod ?{Colour|Black, --set lightColor#000000|Silver, --set lightColor#c0c0c0|Gray, --set lightColor#808080|White, --set lightColor#ffffff|Maroon, --set lightColor#800000|Red, --set lightColor#ff0000|Purple, --set lightColor#800080|Fuchsia, --set lightColor#9900ff|Pink, --set lightColor#ffc0cb|Green, --set lightColor#008000|Lime, --set lightColor#00ff00|Olive, --set lightColor#808000|Yellow, --set lightColor#ffff00|Navy, --set lightColor#000080|Blue, --set lightColor#0000ff|Teal, --set lightColor#008080|Aqua, --set lightColor#00ffff|Orange, --set lightColor#ffa500|-,
|Aquamarine, --set lightColor#7fffd4|Coral, --set lightColor#ff7f50|Cornflowerblue, --set lightColor#6495ed|Crimson, --set lightColor#dc143c|Darkcyan, --set lightColor#008b8b|Darkgreen, --set lightColor#006400|Darkseagreen, --set lightColor#8fbc8f|Deeppink, --set lightColor#ff1493|Firebrick, --set lightColor#b22222|Gold, --set lightColor#ffd700|Goldenrod, --set lightColor#daa520|Lavender, --set lightColor#e6e6fa|Orangered, --set lightColor#ff4500|Saddlebrown, --set lightColor#8b4513|Salmon, --set lightColor#fa8072|Seagreen, --set lightColor#2e8b57|Skyblue, --set lightColor#87ceeb|Violet, --set lightColor#ee82ee|Wheat, --set lightColor#f5deb3|-,
|Clear, --set lightColor#transparent}

July 23 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Nice!

July 26 (3 years ago)

Edited July 29 (3 years ago)

I have updated the macro to include toggles for common light sources and vision/darkvision. Trying to create an all-in-one light/vision macro. After you choose the appropriate light source you can then decide the colour. I haven't yet figured out the command to set the directionality of the light, but I would like to do that for the bullseye lantern. In addition to TokenMod, you must also add APILogic and libInline to your API script library for the macro to function. Thank you to timmaugh for the massive help with the coding.

?{
Light/Vision options:
|Fireflies (dim5),
!token-mod --set emits_bright_light#off emits_low_light#on bright_light_distance#0 low_light_distance#5
|Candle (br5/dim10),
!token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#5 low_light_distance#5
|Dancing Lights (dim10),
!token-mod --set emits_bright_light#off emits_low_light#on bright_light_distance#0 low_light_distance#10
|Lamp (br15/dim45),
!token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#15 low_light_distance#30
|Lightsword (br15/dim30),
!token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#15 low_light_distance#15
|Torch/Light Cantrip (br20/dim40),
!token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#20 low_light_distance#20
|Hooded Lantern (br30/dim60),
!token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#30 low_light_distance#30
|Bullseye Lantern (br40/dim80),
!token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#40 low_light_distance#40
|Create Bonfire (br40/dim80),
!token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#40 low_light_distance#40
|Lighting off,
!token-mod --set emits_bright_light#off emits_low_light#off bright_light_distance#0 low_light_distance#0
|Normal vision,
!token-mod --on has_bright_light_vision emits_bright_light emits_low_light --set bright_light_distance#0 low_light_distance#0
|Darkvision on,
!token-mod --set has_bright_light_vision#on has_night_vision#on night_vision_distance#60 night_vision_effect#nocturnal
|Superior Darkvision on,
!token-mod --set has_bright_light_vision#on has_night_vision#on night_vision_distance#120 night_vision_effect#nocturnal
|Darkvision off,
!token-mod --set has_bright_light_vision#on has_night_vision#off
|Blinded,
!token-mod --set has_bright_light_vision#off
has_night_vision#off
defaulttoken
}
!{&if None = ?{Select Colour?|None|Aqua,00ffff|Aquamarine,7fffd4|Black,000000|Blue,0000ff|Coral,ff7f50|Cornflowerblue,6495ed|Crimson,dc143c|Darkcyan,008b8b|Darkgreen,006400|Darkseagreen,8fbc8f|Deeppink,ff1493|Firebrick,b22222|Fuchsia,9900ff|Gold,ffd700|Goldenrod,daa520|Gray,808080|Green,008000|Lavender,e6e6fa|Lime,00ff00|Maroon,800000|Navy,000080|Olive,808000|Orange,ffa500|Orangered,ff4500|Pink,ffc0cb|Purple,800080|Rebeccapurple,663399|Red,ff0000|Saddlebrown,8b4513|Salmon,fa8072|Seagreen,2e8b57|Silver,c0c0c0|Skyblue,87ceeb|Snow,fffafa|Teal,008080|Transparent,transparent|Violet,ee82ee|Wheat,f5deb3|White,ffffff|Whitesmoke,f5f5f5|Yellow,ffff00}} {&else}token-mod --set lightColor#?{Select Colour?}{&end}



July 26 (3 years ago)
Taz
Pro

Hi - I'm trying to get a token-mod script together for my Sorcerer (we use the Roll20 5E sheet) player who frequently uses Mage Armor (sets AC to 13+Dex Mod) followed by activating Bladesong (adds Int Mod - min of 1 - to AC). So the macro needs to ask if a) activate or inactivate; b) choose Mage Armor or Bladesong then apply (or remove - sets AC = 10+Dex Mod for Mage Armor and reduces by Int Mod for Bladesong) the appropriate bonuses. Can anyone help me? Sorry, I'm no coder!

July 26 (3 years ago)

Edited July 26 (3 years ago)

Taz said:

Hi - I'm trying to get a token-mod script together for my Sorcerer (we use the Roll20 5E sheet) player who frequently uses Mage Armor (sets AC to 13+Dex Mod) followed by activating Bladesong (adds Int Mod - min of 1 - to AC). So the macro needs to ask if a) activate or inactivate; b) choose Mage Armor or Bladesong then apply (or remove - sets AC = 10+Dex Mod for Mage Armor and reduces by Int Mod for Bladesong) the appropriate bonuses. Can anyone help me? Sorry, I'm no coder!

Edit: I just realized this has a nested query error which won't work on the regular server until they roll out the updates that are currently on the dev server for nested queries.  If that happens in the next week or two then this will work (I just tested it on dev); until then you'll have to figure out the html replacements for a nested query.

Or you can use this version that doesn't have the minimum bonus of +1 to Bladesong:

!token-mod --set bar2_current|=[[13?{Mage Armor?|Yes,+@{selected|dexterity_mod}|No,}?{Bladesinging Active?|Yes,+@{selected|intelligence_mod}|No,}]]

Here is a TokenMod macro that assumed the AC value is in Bar2:

!token-mod --set bar2_current|=[[13?{Mage Armor?|Yes,+@{selected|dexterity_mod}|No,}?{Bladesinging Active?|Yes,+[[{@{selected|intelligence_mod},1}kh1]]|No,}]]

To use TokenMod, you'll need to have AC in one of the bar values. You could instead use ChatSetAttr to adjust the character's AC regardless of which bar value it is in.

If you have 'playerscanids' turned on for TokenMod, then you could set a static button for a character instead of having to select the token first.

July 27 (3 years ago)

Edited July 27 (3 years ago)

I'm trying to use token-mod to move a target token as an effect of a Gust of Wind spell, but I can't seem to figure out how to make it work inside of a script. Any suggestions?

!scriptcards{{
  --#title|Gust of Wind
  --#titlecardbackground|#65689E
  --#evenrowbackground|#C2C3DD
  --#oddrowbackground|#D8D9E9
  --#evenrowfontcolor|#020202
  --#oddrowfontcolor|#020202
  --#sourceToken|@{selected|token_id}
  --#targetToken|@{target|token_id}
  --#rightsub|Range: 10 feet 
  --#leftsub|DC: @{selected|spell_save_dc}
  --#emoteText| @{selected|token_name} Casts a Gust of Wind towards @{target|token_name}.
  --@token-mod _config|players-can-ids|on
  --&TokenId|@{selected|token_id}

  --=DC|@{selected|spell_save_dc}
  --=SavingThrow|1d20 + @{target|constitution_save_bonus}
  -->PlayEffects|none;none;breath-smoke;-spell-gustofwind
  --@{selected|token_id}|_token-mod| _set statusmarkers|concentrating::4276403
  --@token-mod @{selected|token_id}|_move|3g
  --+|**@{target|token_name}** made a  [$SavingThrow] Constitution Saving Throw. 
  --?[$SavingThrow] -ge [$DC]|Miss

  -->GetAndCheckSlotInformation|

   --:Hit|
  --+|**@{target|token_name}** failed the saving throw is pushed 15 feet away from you in a direction following the line of wind.
  --X|

  --:Miss|
  --+|**@{target|token_name}** resisted the effects of your Gust of Wind.
  --X|

  --:PlayEffects|Parameters are: source effect;target effect;line effect;sound effect
  --vtoken|@{selected|token_id} [%1%]
  --vtoken|@{target|token_id} [%2%]
  --vbetweentokens|@{selected|token_id} @{target|token_id} [%3%]
  --@roll20AM|_audio,play,nomenu|[%4%]
  --<|
}}
July 27 (3 years ago)

Edited July 27 (3 years ago)

I think your API syntax is wrong.  You might try:

--@token-mod|_move 3g _ids @{selected|token_id}

This should also work since you already have the token selected:

--@token-mod|_move 3g 

Also, make sure the token-mod configuration setting "Players can Ids" is turned on (!token-mod --config).

Edit: I just tested this and it works on a selected token:

!script {{  
  --#hidecard|1
--@token-mod|_move 3g 
}}


Fun little joystick scriptcard:

!script {{  
  --#reentrant|MoveToken
  --#title|Move Token

  --&tStyle|style = "width:100%;padding:1px;border-spacing:0px;border-collapse:collapse;text-shadow: 0px 0px 0px black;border:0px dashed black;"
  --&trStyle1|style="border-top:0px dashed black;"
  --&tdStyle1|style="width:33%;text-align:center;background-color:#FFFFFF;font-size:80%"
  
  --+|[t [&tStyle]]
      [tr [&trStyle1]]
          [td [&tdStyle1]][rbutton]NW::MOVE_TOKEN;315[/rbutton][/td]
          [td [&tdStyle1]][rbutton]N::MOVE_TOKEN;0[/rbutton][/td]
          [td [&tdStyle1]][rbutton]NE::MOVE_TOKEN;45[/rbutton][/td]
        [/tr][tr [&trStyle1]]
          [td [&tdStyle1]][rbutton]W::MOVE_TOKEN;270[/rbutton][/td]
          [td [&tdStyle1]][/td]
          [td [&tdStyle1]][rbutton]E::MOVE_TOKEN;90[/rbutton][/td]
        [/tr][tr [&trStyle1]]
          [td [&tdStyle1]][rbutton]SW::MOVE_TOKEN;225[/rbutton][/td]
          [td [&tdStyle1]][rbutton]S::MOVE_TOKEN;180[/rbutton][/td]
          [td [&tdStyle1]][rbutton]SE::MOVE_TOKEN;135[/rbutton][/td]
        [/tr]
      [/t]
  
  --X|

--:MOVE_TOKEN|
  --#hidecard|1
  --@token-mod|_move =[&reentryval]|1u
  --x|
}}



July 27 (3 years ago)

Edited July 27 (3 years ago)
timmaugh
Pro
API Scripter


Will M. said:

Edit: I just tested this and it works on a selected token:

!script {{  
  --#hidecard|1
--@token-mod|_move 3g 
}}


This works if you have SelectManager installed... otherwise, TokenMod won't see any token as selected.

So, 2 options:

1) use the --ids argument of TokenMod and make sure players-can-ids is "ON", the way Will described, or...

2) install SelectManager



July 27 (3 years ago)


timmaugh said:


Will M. said:

Edit: I just tested this and it works on a selected token:

!script {{  
  --#hidecard|1
--@token-mod|_move 3g 
}}


This works if you have SelectManager installed... otherwise, TokenMod won't see any token as selected.

So, 2 options:

1) use the --ids argument of TokenMod and make sure players-can-ids is "ON", the way Will described, or...

2) install SelectManager


Thank you timmaugh, much appreciated




July 27 (3 years ago)

Edited July 27 (3 years ago)


Will M. said:

Fun little joystick scriptcard:

!script {{  
  --#reentrant|MoveToken
  --#title|Move Token

  --&tStyle|style = "width:100%;padding:1px;border-spacing:0px;border-collapse:collapse;text-shadow: 0px 0px 0px black;border:0px dashed black;"
  --&trStyle1|style="border-top:0px dashed black;"
  --&tdStyle1|style="width:33%;text-align:center;background-color:#FFFFFF;font-size:80%"
  
  --+|[t [&tStyle]]
      [tr [&trStyle1]]
          [td [&tdStyle1]][rbutton]NW::MOVE_TOKEN;315[/rbutton][/td]
          [td [&tdStyle1]][rbutton]N::MOVE_TOKEN;0[/rbutton][/td]
          [td [&tdStyle1]][rbutton]NE::MOVE_TOKEN;45[/rbutton][/td]
        [/tr][tr [&trStyle1]]
          [td [&tdStyle1]][rbutton]W::MOVE_TOKEN;270[/rbutton][/td]
          [td [&tdStyle1]][/td]
          [td [&tdStyle1]][rbutton]E::MOVE_TOKEN;90[/rbutton][/td]
        [/tr][tr [&trStyle1]]
          [td [&tdStyle1]][rbutton]SW::MOVE_TOKEN;225[/rbutton][/td]
          [td [&tdStyle1]][rbutton]S::MOVE_TOKEN;180[/rbutton][/td]
          [td [&tdStyle1]][rbutton]SE::MOVE_TOKEN;135[/rbutton][/td]
        [/tr]
      [/t]
  
  --X|

--:MOVE_TOKEN|
  --#hidecard|1
  --@token-mod|_move =[&reentryval]|1u
  --x|
}}


Thank you Will M., much appreciated. Follow-up question, is there some way I could incorporate your joystick into the script I created for a Gust of Wind? So I could move a token 3 grids in a particular direction?





July 27 (3 years ago)

Edited July 27 (3 years ago)

Change the line:

--@token-mod|_move =[&reentryval]|1u

to 

--@token-mod|_move =[&reentryval]|3u


You might even be able to use t-top and t-left of both caster and the impacted targets to calculate the angle.  I'll take a look at the math and see if I can come up with the correct slope calc formula.

July 27 (3 years ago)


Will M. said:

Change the line:

--@token-mod|_move =[&reentryval]|1u

to 

--@token-mod|_move =[&reentryval]|3u


Yes I see that, but I meant how would I be able to call your script from the Gust of Wind script or incorporate it into the the Gust of Wind script so it queries what direction when someone casts Gust of Wind?

July 27 (3 years ago)

Edited July 29 (3 years ago)

Quick and dirty "Gust of Wind" scriptcard:

!script {{
  --#title|Spell: Gust of Wind
  --#reentrant|GustOfWind
  --#debug|1
  --#sourcetoken|@{selected|token_id}
  --#targettoken|@{target|token_id}

  --&TTokenId|@{target|token_id}
  --=SpellSaveDC|[*S:spell_save_dc]
  --=Result|1d20 + [*T:strength_save_bonus]

  --?[$Result.Base] -eq 1|TARGET_FAILED
  --?[$Result.Base] -eq 20|TARGET_PASSED
  --?[$Result.Raw] -lt [$SpellSaveDC]|TARGET_FAILED
  
  --:TARGET_PASSED|
    --+|Target [b]succeeded[/b] on their strength saving throw with a [$Result] vs. Spellsave DC of [$SpellSaveDC]
    --x|

  --:TARGET_FAILED|
    --+|Target [b]failed[/b] on their strength saving throw with a [$Result] vs. Spellsave DC of [$SpellSaveDC]

    --&tStyle|style = "width:100%;padding:1px;border-spacing:0px;border-collapse:collapse;text-shadow: 0px 0px 0px black;border:0px dashed black;"
    --&trStyle1|style="border-top:0px dashed black;"
    --&tdStyle1|style="width:33%;text-align:center;background-color:#FFFFFF;font-size:80%"
    
    --+|[t [&tStyle]]
        [tr [&trStyle1]]
            [td [&tdStyle1]][rbutton]NW::MOVE_TOKEN;315[/rbutton][/td]
            [td [&tdStyle1]][rbutton]N::MOVE_TOKEN;0[/rbutton][/td]
            [td [&tdStyle1]][rbutton]NE::MOVE_TOKEN;45[/rbutton][/td]
          [/tr][tr [&trStyle1]]
            [td [&tdStyle1]][rbutton]W::MOVE_TOKEN;270[/rbutton][/td]
            [td [&tdStyle1]][/td]
            [td [&tdStyle1]][rbutton]E::MOVE_TOKEN;90[/rbutton][/td]
          [/tr][tr [&trStyle1]]
            [td [&tdStyle1]][rbutton]SW::MOVE_TOKEN;225[/rbutton][/td]
            [td [&tdStyle1]][rbutton]S::MOVE_TOKEN;180[/rbutton][/td]
            [td [&tdStyle1]][rbutton]SE::MOVE_TOKEN;135[/rbutton][/td]
          [/tr]
        [/t]
  
  --X|

--:MOVE_TOKEN|
  --#hidecard|1
  --/|*MoveToken|[&TTokenId] ([&reentryval])
  --@token-mod|_move =[&reentryval]|3u _ids [&TTokenId] _ignore-selected
  --x|
}}


A more advanced version of this script could automatically calculate the angle between the caster and target and force the target to move in the appropriate direction if it fails.  

Edit:  Thanks to Kurt's quick turnaround on a new version of ScriptCards.  I was able to change the code above to now incorporate his new Angle function.  The new "Gust of Wind" code is below:

Update 7/29/2021:

  • Updated to account for 5e grid spacing when moving tokens diagonally.
  • Updated to handle a small issue with angle function (fixed in SC 1.3.9b) returning negative angels between 270 and 360 degrees
!script {{
  --#title|Spell: Gust of Wind
  --#reentrant|GustOfWind
  --#debug|1
  --#sourcetoken|@{selected|token_id}
  --#targettoken|@{target|token_id}

  --&TTokenId|@{target|token_id}
  --=SpellSaveDC|[*S:spell_save_dc]
  --=Result|1d20 + [*T:strength_save_bonus]

  --?[$Result.Base] -eq 1|TARGET_FAILED
  --?[$Result.Base] -eq 20|TARGET_PASSED
  --?[$Result.Raw] -lt [$SpellSaveDC]|TARGET_FAILED
  
  --:TARGET_PASSED|
    --+|Target [b]succeeded[/b] on their strength saving throw with a [$Result] vs. Spellsave DC of [$SpellSaveDC]
    --x|

  --:TARGET_FAILED|
    --+|Target [b]failed[/b] on their strength saving throw with a [$Result] vs. Spellsave DC of [$SpellSaveDC]

    --&tStyle|style = "width:100%;padding:1px;border-spacing:0px;border-collapse:collapse;text-shadow: 0px 0px 0px black;border:0px dashed black;"
    --&trStyle1|style="border-top:0px dashed black;"
    --&tdStyle1|style="width:33%;text-align:center;background-color:#FFFFFF;font-size:80%"
    
    --/| Angle function returns a string variable (&) with lots of decimal points.
    --~A|math;angle;@{selected|token_id};@{target|token_id}

    --/| I've found that TokenMod chokes on a movement angle with lots of decimal points, so rounding is needed
    --/|$Ar will now contain a rounded integer version of &A
    --~Ar|math;round;[&A]

    --/|&Angle will end up being one of the common directions which may work better for grids
    --?[$Ar] -gt 337.5 -or [$Ar] -le 22.5|&Angle;0
    --?[$Ar] -gt 22.5 -and [$Ar] -le 67.5|&Angle;45
    --?[$Ar] -gt 67.5 -and [$Ar] -le 112.5|&Angle;90
    --?[$Ar] -gt 112.5 -and [$Ar] -le 157.5|&Angle;135
    --?[$Ar] -gt 157.5 -and [$Ar] -le 202.5|&Angle;180
    --?[$Ar] -gt 202.5 -and [$Ar] -le 247.5|&Angle;225
    --?[$Ar] -gt 247.5 -and [$Ar] -le 292.5|&Angle;270
    --?[$Ar] -gt 292.5 -and [$Ar] -le 337.5|&Angle;315

    --/| Added for dealing with a SC 1.39a bug (returns negative angles beteen 270 and 360)
    --?[$Ar] -gt -90 -and [$Ar] -le -67.5|&Angle;270
    --?[$Ar] -gt -67.5 -and [$Ar] -le -22.5|&Angle;315
    --?[$Ar] -gt -22.5 -and [$Ar] -le 0|&Angle;0

    --&UnitsFactor|1
    --?[&Angle] -eq 45|&UnitsFactor;1.4142
    --?[&Angle] -eq 135|&UnitsFactor;1.4142
    --?[&Angle] -eq 225|&UnitsFactor;1.4142
    --?[&Angle] -eq 315|&UnitsFactor;1.4142

    --=U|3 * [&UnitsFactor] 

    --/|*Angles|[&Angle] ([&A]) ([$Ar]) 
    --/| Time to call the magic TokenMod function to make the target token move across the screen
    --@token-mod|_move =[&Angle]|[$U.Raw]g _ids @{target|token_id} _ignore-selected

  --X|
}}


July 27 (3 years ago)

Edited July 27 (3 years ago)


Will M. said:

Quick and dirty "Gust of Wind" scriptcard:

A more advanced version of this script could automatically calculate the angle between the caster and target and force the target to move in the appropriate direction if it fails.  

Thank you, yes, am now working on trying to have the script do just that. But you have help me enormously with moving forward with the Gust of Wind. I'm completely new to all of this and have been just taking others scripts and modifying them to work with other spells, by changing a line at a time to see what happens, I was very successful with your Mark/Clear Conditions and Status script. I probably would  save myself a lot of effort if I just bought a book on the basics so I understand more.

Thanks again, do appreciate your time and effort.




July 28 (3 years ago)

Edited July 28 (3 years ago)

Whenever I set up sight with Token Mod it always makes any emitting light seem like darkness. It's usually a quick fix by opening and closing the token and opening the sheet to set it as the default token. So wondering if there is something wrong with the following macro.

!token-mod {{
--set 
       bar1|@{selected|hp|max}
       bar2_value|@{selected|npc_ac}
       bar3_value|[[10 + [[@{selected|npc_perception}]]]]
       width|?{Size?|Medium,70|Large,140|Huge,210| Gargantuan,280} height|?{Size?|Medium,70|Large,140|Huge,210| Gargantuan,280}
       has_bright_light_vision|true
       has_night_vision|true
       night_vision_distance|?{Other Vision|0}
       night_vision_effect|dimming|?{Dim Start|5}
--off showname 
}}

Along the same lines of issues. When I set up the lighting correctly, and then use the !token-mod --set defaulttoken command, the working token when re-dragged out changes to seeing all emitting light as darkness again. Its easy enough to work around, just wondering if I've misunderstand the commands I'm meant to be using to make this work properly.

Left Quasit was manually set up and dragged out working as normal. The Right Quasit was re-dragged out after using the !token-mod --set defaulttoken command
July 28 (3 years ago)

I'm not getting that behavior, so it may be a bug.

Does this happen on all pages?

Does this happen in other games? Have you tried a copy to see if it still happens?

What are your page settings (especially Dynamic Lighting)?


And just a couple notes:

You can change this line

       width|?{Size?|Medium,70|Large,140|Huge,210| Gargantuan,280} height|?{Size?|Medium,70|Large,140|Huge,210| Gargantuan,280}
to
       scale|?{Size?|Medium,70|Large,140|Huge,210|Gargantuan,280}

or units:

       scale|?{Size?|Medium,1|Large,2|Huge,3|Gargantuan,4}u

because 'scale' will resize both width and height.

It also looks like you are always setting 'has_night_vision' to true.  Then you have a query that defaults the night_vision_distance to 0 and night_vision_effect to dimming with a 'start' of 5, but the 'start' cannot be a higher number than the 'night_vision_distance', and most players prefer to have the dimming start at 0 to simulate darkvision. So you may want to consider this:
       has_night_vision|?{Darkvision?|Yes,on|No,off}
       night_vision_distance|?{Other Vision|60}
       night_vision_effect|dimming|?{Dim Start|0}

Thanks for the Macro edits n_n


Does this happen on all pages?

I recreated the bug on 20 of my pages with Dynamic lighting. I can post pictures of it on other pages if you need. I've already tried disabling other scripts and reinstalling the script through the API library. Still occurs. 

Does this happen in other games? Have you tried a copy to see if it still happens? 

Copy and pasting the token, the new token also sees emitted light from other tokens light as darkness. Also just tried in another one of my games and does it there as well.

What are your page settings (especially Dynamic Lighting)?

On the  Page Details I have:

                    Size 40x30 
                    Background - Black
                    Scale - Grid Cell Distance at 5ft
                    Grig Type - Square
                    Grid Measurements - D&D 5E/4E Compatible 
                    Grid Cell Width 1 x 70px
                    Grid COlour Red (Opacity 50%)
                    Movement - Dynamic Lighting Barriers Restrict Movement 
                    Fog of War - Off

                    On the Dynamic Lighting Page I have:

                    Dynamic Lighting - On
                    Explore Mode - Off
                    Daylight Mode - Off 
                    Update when Token Drop - On (Already tried moving the token around, as I thought this might be causing the error)
                    GM Darkness Opacity - 35%
                    Legacy Lighting - Off
                    July 28 (3 years ago)

                    @ez2rpg - There will be a new Scriptcards coming out that has an angle function.  We will be able to add this easily here in the near future so you wont even need to use the Joystick function.

                    Once this new version comes out, I'll probably create a Shove script card that will do the str vs. str/dex and then apply the desired effect.  Prone or Pushed back 5 ft.

                    ez2rpg said:


                    Will M. said:

                    Quick and dirty "Gust of Wind" scriptcard:

                    A more advanced version of this script could automatically calculate the angle between the caster and target and force the target to move in the appropriate direction if it fails.  

                    Thank you, yes, am now working on trying to have the script do just that. But you have help me enormously with moving forward with the Gust of Wind. I'm completely new to all of this and have been just taking others scripts and modifying them to work with other spells, by changing a line at a time to see what happens, I was very successful with your Mark/Clear Conditions and Status script. I probably would  save myself a lot of effort if I just bought a book on the basics so I understand more.

                    Thanks again, do appreciate your time and effort.







                    July 28 (3 years ago)

                    Nox said:

                    Does this happen on all pages?

                    I recreated the bug on 20 of my pages with Dynamic lighting. I can post pictures of it on other pages if you need. I've already tried disabling other scripts and reinstalling the script through the API library. Still occurs. 

                    Does this happen in other games? Have you tried a copy to see if it still happens? 

                    Copy and pasting the token, the new token also sees emitted light from other tokens light as darkness. Also just tried in another one of my games and does it there as well.

                    What are your page settings (especially Dynamic Lighting)?

                    On the  Page Details I have:

                                      Size 40x30 
                                      Background - Black
                                      Scale - Grid Cell Distance at 5ft
                                      Grig Type - Square
                                      Grid Measurements - D&D 5E/4E Compatible 
                                      Grid Cell Width 1 x 70px
                                      Grid COlour Red (Opacity 50%)
                                      Movement - Dynamic Lighting Barriers Restrict Movement 
                                      Fog of War - Off

                                      On the Dynamic Lighting Page I have:

                                      Dynamic Lighting - On
                                      Explore Mode - Off
                                      Daylight Mode - Off 
                                      Update when Token Drop - On (Already tried moving the token around, as I thought this might be causing the error)
                                      GM Darkness Opacity - 35%
                                      Legacy Lighting - Off

                                      It looks like this isn't an issue with TokenMod, but a bug relating to how the 'setdefaulttoken' API command is interacting with UDL settings.  I'd suggest posting it in the UDL Bug Thread.

                                      Also, the last troubleshooting checks that I would suggest:

                                      How are you checking the vision settings on the token? If you're using Ctrl-L or 'Rejoin as Player' there can be some funky results. I always suggest using a Dummy Account to check vision settings for your players.

                                      Which browser are you using? Chrome and Firefox are the only two that are officially supported, so I would test in those and make sure to use a private/incognito window without any browser extensions to confirm those are not causing any issues. And if you have access to another computer it could be helpful to see if it's isolated to your machine.

                                      July 28 (3 years ago)


                                      Will M. said:

                                      @ez2rpg - There will be a new Scriptcards coming out that has an angle function.  We will be able to add this easily here in the near future so you wont even need to use the Joystick function.

                                      Once this new version comes out, I'll probably create a Shove script card that will do the str vs. str/dex and then apply the desired effect.  Prone or Pushed back 5 ft.

                                      ez2rpg said:


                                      Will M. said:

                                      Quick and dirty "Gust of Wind" scriptcard:

                                      A more advanced version of this script could automatically calculate the angle between the caster and target and force the target to move in the appropriate direction if it fails.  

                                      Thank you, yes, am now working on trying to have the script do just that. But you have help me enormously with moving forward with the Gust of Wind. I'm completely new to all of this and have been just taking others scripts and modifying them to work with other spells, by changing a line at a time to see what happens, I was very successful with your Mark/Clear Conditions and Status script. I probably would  save myself a lot of effort if I just bought a book on the basics so I understand more.

                                      Thanks again, do appreciate your time and effort.

                                      Great news! Thank you, I'll keep my eyes and ears open for it.





                                      July 28 (3 years ago)

                                      @ez2rpg - I posted the new "Gust of Wind" function that uses the angle function included in the latest scriptcards script (1.39a still on the dev gist).  It's in the post above where I posted my original script.  


                                      Jarren K. said:

                                      It looks like this isn't an issue with TokenMod, but a bug relating to how the 'setdefaulttoken' API command is interacting with UDL settings.  I'd suggest posting it in the UDL Bug Thread.

                                      Also, the last troubleshooting checks that I would suggest:

                                      How are you checking the vision settings on the token? If you're using Ctrl-L or 'Rejoin as Player' there can be some funky results. I always suggest using a Dummy Account to check vision settings for your players.

                                      Which browser are you using? Chrome and Firefox are the only two that are officially supported, so I would test in those and make sure to use a private/incognito window without any browser extensions to confirm those are not causing any issues. And if you have access to another computer it could be helpful to see if it's isolated to your machine.

                                      I've Posted the Issue on the UDL Bug Thread Here so hopefully they can assist. Thank you for your advice n_n

                                      Dummy Account still see the same thing. Calling in a few of my friends to join the game to test the bug on their PC's for a wider data set, they all saw the same thing. I'm also using Chrome and Disabling all my three Extensions did nothing to alter the bug.

                                      July 29 (3 years ago)

                                      @The Aaron - Did you ever update TokenMod to handle diagonal grid movements for 5e?

                                      Here's a link from earlier this year describing the issue.  when issuing the --move options with g or u units option, the token doesn't move completely into the diagonal (45 degrees) square.

                                      July 29 (3 years ago)


                                      Will M. said:

                                      @ez2rpg - I posted the new "Gust of Wind" function that uses the angle function included in the latest scriptcards script (1.39a still on the dev gist).  It's in the post above where I posted my original script.  


                                      Thank you, it works great!

                                      July 29 (3 years ago)

                                      @ez2rpg - You might post this to the ScriptCards forum or create a new one.  This forum is for TokenMod.

                                      August 05 (3 years ago)

                                      Hey @The Aaron, thanks for your great work.

                                      But I have a little hickup here : )
                                      I made two macros, one for emitting an aura light from a token, and one for a cone.
                                      The first time I use one of the macros (does not matter which), everything is fine. When I hit the other macro after the first was executed
                                      the values in the tokens dynamic light settings are set, but they will only apply if I open the settings and save them (without changing anything).

                                      Any ideas?


                                      #Aura
                                      !token-mod {{
                                      --set
                                      has_directional_bright_light|no
                                      has_directional_low_light|no
                                      directional_bright_light_center|0
                                      directional_low_light_center|0
                                      directional_bright_light_total|0
                                      directional_low_light_total|0
                                      emits_bright_light|yes
                                      emits_low_light|yes
                                      bright_light_distance|20
                                      low_light_distance|20
                                      light_radius|40
                                      light_dimradius|20
                                      }}

                                      #Cone
                                      !token-mod {{
                                      --set
                                      has_directional_bright_light|yes
                                      has_directional_low_light|yes
                                      directional_bright_light_center|0
                                      directional_low_light_center|0
                                      directional_bright_light_total|90
                                      directional_low_light_total|90
                                      emits_bright_light|yes
                                      emits_low_light|yes
                                      bright_light_distance|20
                                      low_light_distance|20
                                      light_radius|40
                                      light_dimradius|20
                                      }}