Snooze said: I'm having an issue with conditional statements, im assuming im doing a small obvious thing wrong but cant seem to figure out what. The aim of the script is to for the selected token (at some point need to change it to work with multiple non identical selected, but want to fix conditionals first prior to dealing with the looping) set their hp to the maximum, for npcs only. logic behind it is, get the hp formular, then since i cant find a way to just calculate maximum, find the value infront of the d, which gives the number of dice, the number after the d but before either the + or - (mostly focusing on the + situation as - is rare) which is the type of dice, then the modifier comes after the +. this is my issue area as doing this when there is no + causes issues. so want a conditional to find the +,-,or neither then do the appropriate bit. each of these functions does what i want, but from testing the conditions clearly arent applying and its failign both and going straight through to no mod. (the random --+ statements where to help me attempt (and clearly fail) to debug this issue) all variables except mod are coming out as expected, and mod is due to it just going straight to no mod. so any help would be much appreciated! The issue with your code above is this line: -?[&hp] -inc "+"|POSTIVE_MOD because "POSITIVE_MOD" is misspelled :) (also, [&hp] should be in quotes since the formula contains a space) That said, here is how I would handle what you are doing. This uses the new looping structures that were introduced in 2.1.8 (OneClick is now on 2.1.11, so these should be widely available now). I've included more or less line-by-line comments. This will operate on all tokens you have selected, and uses the --! attribute modification command to set the bar1 max and bar 1 value values. !script {{
--/|Make sure we have some tokens selected, otherwise quit
--?"[@SC_SelectedTokens(maxindex)]" -eq "undefined array"|END
--/|Loop through all the selected tokens
--%loop|foreach;SC_SelectedTokens
--/|If the token doesn't represent a character, skip it
--?"X[*[&loop]:t-represents]" -eq "X"|%
--/|If the character is not an NPC, skip it
--?"X[*[&loop]:npc]" -ne "X1"|%
--/|Convert the HP formula to a max hp calculation by replacing "d" with "*"
--~hpinfo|string;replace;d;*;[*[&loop]:npc_hpformula]
--/|Calculate Max HP
--=MaxHP|[&hpinfo]
--/|Display the character name and max hp
--+[*[&loop]:name]|[$MaxHP]
--/|Set to bar1 max (first) then bar1 value for the token to the max hp
--!t:[&loop]|bar1_max:[$MaxHP.Raw]|bar1_value:[$MaxHP.Raw]
--%|
--:END|
}}