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

Help using token mod to track fly/burrow height and display correct icon.

I'm a little stuck trying to implement this, but I'm not much of a coder... I'm trying to use token mod to pull/write in bar 3 (height) with anything higher than 0 would add a flight marker while anything under 0 would add a burrow icon. No icon displayed for 0. I'd love to somehow make the token go to gm layer when bar 3 is negative but I have no idea how to do this without an if statement. It's very similar to the flight API but with a few additions that token mod might be able to pull off. I've read the script cards can use if statements but I've never used them before. Would script cards be a possible solution? D oes anyone have ideas to get this done?
ScriptCards is a possible solution to this. I suspect some MetaScripts could also make this work. But to me it sounds like you or a player want to manually make a change to a token's bar 3 value and then have that automatically make an adjustment to the token. If I have that correct, then it sounds like a good case for a ScriptCards Trigger &nbsp;in particular a trigger on change:graphic. !script {{ --/|CONFIGURATION VARIABLES --&amp;BarNumberToMonitor|3 --&amp;FlightMarker|red --&amp;BurrowMarker|blue --/|TRIGGER_REPLACEMENTS --#hidecard|1 --?[&amp;GraphicNewbar[&amp;BarNumberToMonitor]_value] -gt 0|Positive --?[&amp;GraphicNewbar[&amp;BarNumberToMonitor]_value] -lt 0|Negative --?[&amp;GraphicNewbar[&amp;BarNumberToMonitor]_value] -eq 0|Zero --:Done| --X| --:Positive| --&gt;LibSN_REMOVE_STATUS_MARKER|[&amp;GraphicNew_id];[&amp;BurrowMarker] --&gt;LibSN_ADD_STATUS_MARKER|[&amp;GraphicNew_id];[&amp;FlightMarker] --^Done| --:Negative| --&gt;LibSN_REMOVE_STATUS_MARKER|[&amp;GraphicNew_id];[&amp;FlightMarker] --&gt;LibSN_ADD_STATUS_MARKER|[&amp;GraphicNew_id];[&amp;BurrowMarker] --!graphic:[&amp;GraphicNew_id]|layer:gmlayer --^Done| --:Zero| --&gt;LibSN_REMOVE_STATUS_MARKER|[&amp;GraphicNew_id];[&amp;FlightMarker] --&gt;LibSN_REMOVE_STATUS_MARKER|[&amp;GraphicNew_id];[&amp;BurrowMarker] --^Done| --/|Below all taken from Kurt J's system neutral library. Copied here to not need to import the library for this example --/|<a href="https://raw.githubusercontent.com/kjaegers/ScriptCards/main/ScriptCards_Examples/libraries/systemneutrallib.scard" rel="nofollow">https://raw.githubusercontent.com/kjaegers/ScriptCards/main/ScriptCards_Examples/libraries/systemneutrallib.scard</a> --:LibSN_ADD_STATUS_MARKER|Token_ID;Status Marker;Count --&gt;LibSN_REMOVE_STATUS_MARKER|[%1%];[%2%] --~|array;statusmarkers;Conditions;[%1%] --&amp;toAdd|[%2%] --?"[%2%]" -ne "dead" -and "X[%3%]" -ne "X" -and "X[%3%]" -ne "X0"|=countToAdd;[%3%] {MIN:0} {MAX:9} --?"[%2%]" -ne "dead" -and "X[%3%]" -ne "X" -and "X[%3%]" -ne "X0"|&amp;toAdd;[%2%]@[$countToAdd.Raw] --~|array;add;Conditions;[&amp;toAdd] --~newConditions|array;stringify;Conditions --#parameterdelimiter|$ --~newConditions|string$replaceall$;$,$[&amp;newConditions] --#parameterdelimiter|; --?"[&amp;newConditions(0,1)]" -eq ","|&amp;newConditions;[&amp;newConditions(1)] --!t:[%1%]|statusmarkers:[&amp;newConditions] --&lt;| --:LibSN_REMOVE_STATUS_MARKER|Token_ID;Status Marker --&gt;LibSN_CHECK_STATUS_MARKER|[%1%];[%2%];MarkerExists;MarkerCounter --?[&amp;MarkerExists] -eq 0|&lt; --~|array;statusmarkers;Conditions;[%1%] --?[&amp;MarkerCounter] -eq 0|&amp;toCheckFor;[%2%]|&amp;toCheckFor;[%2%]@[&amp;MarkerCounter] --~hasCondition|array;indexof;Conditions;[&amp;toCheckFor] --?[&amp;hasCondition] -eq "ArrayError"|&lt; --~|array;remove;Conditions;[&amp;toCheckFor] --~newConditions|array;stringify;Conditions --#parameterdelimiter|$ --~newConditions|string$replaceall$;$,$[&amp;newConditions] --#parameterdelimiter|; --!t:[%1%]|statusmarkers:[&amp;newConditions] --&lt;| --:LibSN_CHECK_STATUS_MARKER|TokenID;MarkerToFind;Exists;Counter --~|array;statusmarkers;Conditions;[%1%] --&amp;FoundMarker|-1 --%_libloop|0;[@Conditions(maxindex)] --&amp;Temp|[@Conditions([&amp;_libloop])] --?[&amp;Temp(indexof,[%2%])] -eq 0|&amp;FoundMarker;[&amp;_libloop] --%| --?[&amp;FoundMarker] -ne -1|LibSN_FOUND_STATUS_MARKER --&amp;[%3%]|0 --&amp;[%4%]|0 --&lt;| --:LibSN_FOUND_STATUS_MARKER| --&amp;[%3%]|1 --&amp;[%4%]|0 --&amp;ThisMarker|[@Conditions([&amp;FoundMarker])] --?[&amp;ThisMarker(contains,@)] -eq 0|&lt; --~[%4%]|string;after;@;[@Conditions([&amp;FoundMarker])] --&lt;| }} That ScriptCard copied into an ability named change:graphic &nbsp;on a character named ScriptCards_Triggers, after restarting the API Sandbox, will monitor bar 3 and adjust the markers that are set for FlightMarker and BurrowMarker at the top of the ScriptCard. If bar3 goes negative, it will also move the token to the gmlayer. The stuff at the bottom is just copied from a Library of Kurt's just to make the ScriptCard a bit more self contained. Let me know if you have any questions about it.
I'll check that out! Ya it would be preferable to use the token bar but Creating a stat on character sheet and updating that while linking bar 3 to is more than fine if I can make it functional haha.
1721856121

Edited 1721856153
Hi Joshua, I know nothing, and I mean nothing, about anything beyond very basic Scriptcards, but am following this for education purposes. Should --:Positive have a change graphic to set any token back to the token layer?
It could if that's the functionality desired. It makes sense that it would be but I didn't add out of the gate on the thought that it might not be desired to automatically move a token to the object layer. Let's say you made a change to the bar3 value for a hidden token, I didn't want to automatically assume it should move from gmlayer to token layer. If that is the desired effect to automatically move any token to the objects layer, then this would work: !script {{ --/|CONFIGURATION VARIABLES --&amp;BarNumberToMonitor|3 --&amp;FlightMarker|red --&amp;BurrowMarker|blue --/|TRIGGER_REPLACEMENTS --#hidecard|1 --?[&amp;GraphicOldbar[&amp;BarNumberToMonitor]_value] -eq [&amp;GraphicNewbar[&amp;BarNumberToMonitor]_value]|Done --?[&amp;GraphicNewbar[&amp;BarNumberToMonitor]_value] -gt 0|Positive --?[&amp;GraphicNewbar[&amp;BarNumberToMonitor]_value] -lt 0|Negative --?[&amp;GraphicNewbar[&amp;BarNumberToMonitor]_value] -eq 0|Zero --:Done| --X| --:Positive| --&gt;LibSN_REMOVE_STATUS_MARKER|[&amp;GraphicNew_id];[&amp;BurrowMarker] --&gt;LibSN_ADD_STATUS_MARKER|[&amp;GraphicNew_id];[&amp;FlightMarker] --!graphic:[&amp;GraphicNew_id]|layer:objects --^Done| --:Negative| --&gt;LibSN_REMOVE_STATUS_MARKER|[&amp;GraphicNew_id];[&amp;FlightMarker] --&gt;LibSN_ADD_STATUS_MARKER|[&amp;GraphicNew_id];[&amp;BurrowMarker] --!graphic:[&amp;GraphicNew_id]|layer:gmlayer --^Done| --:Zero| --&gt;LibSN_REMOVE_STATUS_MARKER|[&amp;GraphicNew_id];[&amp;FlightMarker] --&gt;LibSN_REMOVE_STATUS_MARKER|[&amp;GraphicNew_id];[&amp;BurrowMarker] --!graphic:[&amp;GraphicNew_id]|layer:objects --^Done| --/|Below all taken from Kurt J's system neutral library. Copied here to not need to import the library for this example --/|<a href="https://raw.githubusercontent.com/kjaegers/ScriptCards/main/ScriptCards_Examples/libraries/systemneutrallib.scard" rel="nofollow">https://raw.githubusercontent.com/kjaegers/ScriptCards/main/ScriptCards_Examples/libraries/systemneutrallib.scard</a> --:LibSN_ADD_STATUS_MARKER|Token_ID;Status Marker;Count --&gt;LibSN_REMOVE_STATUS_MARKER|[%1%];[%2%] --~|array;statusmarkers;Conditions;[%1%] --&amp;toAdd|[%2%] --?"[%2%]" -ne "dead" -and "X[%3%]" -ne "X" -and "X[%3%]" -ne "X0"|=countToAdd;[%3%] {MIN:0} {MAX:9} --?"[%2%]" -ne "dead" -and "X[%3%]" -ne "X" -and "X[%3%]" -ne "X0"|&amp;toAdd;[%2%]@[$countToAdd.Raw] --~|array;add;Conditions;[&amp;toAdd] --~newConditions|array;stringify;Conditions --#parameterdelimiter|$ --~newConditions|string$replaceall$;$,$[&amp;newConditions] --#parameterdelimiter|; --?"[&amp;newConditions(0,1)]" -eq ","|&amp;newConditions;[&amp;newConditions(1)] --!t:[%1%]|statusmarkers:[&amp;newConditions] --&lt;| --:LibSN_REMOVE_STATUS_MARKER|Token_ID;Status Marker --&gt;LibSN_CHECK_STATUS_MARKER|[%1%];[%2%];MarkerExists;MarkerCounter --?[&amp;MarkerExists] -eq 0|&lt; --~|array;statusmarkers;Conditions;[%1%] --?[&amp;MarkerCounter] -eq 0|&amp;toCheckFor;[%2%]|&amp;toCheckFor;[%2%]@[&amp;MarkerCounter] --~hasCondition|array;indexof;Conditions;[&amp;toCheckFor] --?[&amp;hasCondition] -eq "ArrayError"|&lt; --~|array;remove;Conditions;[&amp;toCheckFor] --~newConditions|array;stringify;Conditions --#parameterdelimiter|$ --~newConditions|string$replaceall$;$,$[&amp;newConditions] --#parameterdelimiter|; --!t:[%1%]|statusmarkers:[&amp;newConditions] --&lt;| --:LibSN_CHECK_STATUS_MARKER|TokenID;MarkerToFind;Exists;Counter --~|array;statusmarkers;Conditions;[%1%] --&amp;FoundMarker|-1 --%_libloop|0;[@Conditions(maxindex)] --&amp;Temp|[@Conditions([&amp;_libloop])] --?[&amp;Temp(indexof,[%2%])] -eq 0|&amp;FoundMarker;[&amp;_libloop] --%| --?[&amp;FoundMarker] -ne -1|LibSN_FOUND_STATUS_MARKER --&amp;[%3%]|0 --&amp;[%4%]|0 --&lt;| --:LibSN_FOUND_STATUS_MARKER| --&amp;[%3%]|1 --&amp;[%4%]|0 --&amp;ThisMarker|[@Conditions([&amp;FoundMarker])] --?[&amp;ThisMarker(contains,@)] -eq 0|&lt; --~[%4%]|string;after;@;[@Conditions([&amp;FoundMarker])] --&lt;| }} So with the above there is a check to see if the bar3 value changed, if it didn't change, then exit the trigger. If bar3 changed, then it will move a token to the objects layer if it is greater than or equal to 0. One thing I'll mention as well, is that typically triggers do not fire when another mod makes the change. ScriptCards does allow you to opt-in to changes made by TokenMod.&nbsp;You can set an attribute on the ScriptCards_Triggers character called 'listen_to_tokenmod' and make its current value 1 to enable this behavior. You should be able to enable this safely because the above code uses only ScriptCards modifications so any TokenMod modifications won't result in a loop.
Joshua N. said: It could if that's the functionality desired. It makes sense that it would be but I didn't add out of the gate on the thought that it might not be desired to automatically move a token to the object layer. Let's say you made a change to the bar3 value for a hidden token, I didn't want to automatically assume it should move from gmlayer to token layer. If that is the desired effect to automatically move any token to the objects layer, then this would work... WOW! I just got home, was getting prepped to dive into Kurt's coding vids. You absolute mad lad its exactly what I was thinking! I Thank you so much! script cards are awesome!
ScriptCards are awesome. Hopefully that helps you and your group have even more fun.
look at the Flight Mod.
Will M. said: look at the Flight Mod. I did, I wanted to use something with a lot more function while actually using flight/burrow/swim effectively. I believe what Joshua made is far more useful.
Thanks Joshua, thorough and very clear as always, much appreciated&nbsp;