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

Condition in Scriptcard

What is wrong with this code? Ideally, it will identify who goes before and after the opponent by rolling a d100 and comparing to the token's Speed score. If they roll under, they go first. If the roll over, the opponent goes first. However, the condition is not working, and it always comes up with the character going before the opponent. !scriptcard {{ --#emoteState|Hidden --~PageTokens|array;pagetokens;Characters;@{selected|token_id};char --~CurrentCharacter|array;getfirst;Characters --#title|Rolling Inititive --:InititiveLoop| --#sourceToken|[&CurrentCharacter] --=CharInitiative|1d100 --=Speed|[*S:speed] --?[$CharInitiative] -lt [$spd][ |*[img width=32 height=32][*S:t-imgsrc][/img] [*S:character_name]; rolls a [$CharInitiative] against Speed of [$Speed] for initiative and goes before the opponents.[br][br]|+[img width=32 height=32][*S:t-imgsrc][/img] [*S:t-name]; rolls a [$CharInitiative] against Speed of [$Speed] for initiative and goes before the opponents.[br][br] --]|[ *[img width=32 height=32][*S:t-imgsrc][/img] [*S:character_name]; rolls a [$CharInitiative] against Speed of [$Speed] for initiative and goes before the opponents.[br][br]|+[img width=32 height=32][*S:t-imgsrc][/img] [*S:t-name]; rolls a [$CharInitiative] against Speed of [$Speed] for initiative and goes after the opponents.[br][br] --]| --~|turnorder;replacetoken;[&CurrentCharacter];[$CharInitiative] --~CurrentCharacter|array;getnext;Characters --?[&CurrentCharacter] -eq ArrayError|InititiveDone|InititiveLoop --:InititiveDone| --~|turnorder;sort }} Rolling Inititive  Lucas  rolls a 39 against Speed of 37 for initiative and goes before the opponents.  Richard Sleeper  rolls a 3 against Speed of 40 for initiative and goes before the opponents.  Ted Ijaz  rolls a 40 against Speed of 42 for initiative and goes before the opponents.  Uriah Jessup  rolls a 52 against Speed of 50 for initiative and goes before the opponents.  Octavian Fuller  rolls a 26 against Speed of 30 for initiative and goes before the opponents.
1694832050
Andrew R.
Pro
Sheet Author
You are setting a Roll Variable $Speed but you are using a Roll Variable $spd which I don’t see you setting anywhere so your Conditional is not working as expected. 
Even with that correction, it's still not working properly. !scriptcard {{ --#emoteState|Hidden --~PageTokens|array;pagetokens;Characters;@{selected|token_id};char --~CurrentCharacter|array;getfirst;Characters --#title|Rolling Inititive --:InititiveLoop| --#sourceToken|[&CurrentCharacter] --=CharInitiative|1d100 --=spd|[*S:speed] --?[$CharInitiative] -lt [$spd][ |*[img width=32 height=32][*S:t-imgsrc][/img] [*S:character_name]; rolls a [$CharInitiative] against Speed of [$spd] for initiative and goes before the opponents.[br][br]|+[img width=32 height=32][*S:t-imgsrc][/img] [*S:t-name]; rolls a [$CharInitiative] against Speed of [$spd] for initiative and goes before the opponents.[br][br] --=|[$Speed] &{tracker} --]|[ *[img width=32 height=32][*S:t-imgsrc][/img] [*S:character_name]; rolls a [$CharInitiative] against Speed of [$spd] for initiative and goes before the opponents.[br][br]|+[img width=32 height=32][*S:t-imgsrc][/img] [*S:t-name]; rolls a [$CharInitiative] against Speed of [$spd] for initiative and goes after the opponents.[br][br] --=|[$Speed] +50 &{tracker} --]| --~|turnorder;replacetoken;[&CurrentCharacter];[$CharInitiative] --~CurrentCharacter|array;getnext;Characters --?[&CurrentCharacter] -eq ArrayError|InititiveDone|InititiveLoop --:InititiveDone| --~|turnorder;sort }}
1694850057
Andrew R.
Pro
Sheet Author
It would help if you told us what game system and character sheet this is for, because it isn't one I know. 
Mothership 1E using the Mothership by Tuesday Knight Games character sheet.
1694874331
Andrew R.
Pro
Sheet Author
You had several syntax errors in your script that you would have found by looking in the Mod Output Console. Here is simplified code that does the Conditional correctly. You can also do this loop using the --% command with the foreach modifier instead of the unstructured way you're doing it.  !scriptcard {{   --#emoteState|Hidden   --#title|Rolling Initiative      --~PageTokens|array;pagetokens;Characters;@{selected|token_id};char   --~CurrentCharacter|array;getfirst;Characters      --:InitiativeLoop|      --#sourceToken|[&CurrentCharacter]      --=CharInitiative|1d100   --&CharName|[*S:character_name]   --=CharSpeed|[*S:speed]   --?[$CharInitiative.Raw] -lt [$CharSpeed.Raw]|[        --+|[&CharName] rolls a [$CharInitiative] versus Speed [$CharSpeed] and goes before the opponents.   --]|[     --+|[&CharName] rolls a [$CharInitiative] versus Speed [$CharSpeed] and goes after the opponents.        --]|      --~|turnorder;replacetoken;[&CurrentCharacter];[$CharInitiative]      --~CurrentCharacter|array;getnext;Characters      --?[&CurrentCharacter] -eq ArrayError|InitiativeDone|InitiativeLoop      --:InitiativeDone|      --~|turnorder;sort }}