i have a problem concerning the usage of an if-condition, when i am trying to use the +-sign from a substring.
i have a variable which has "3W6+3" as its content. Now i am trying to break down the string to get the number of dices, what kind of dice i use and the bonus.
Code: Select all
[h: tmpstring='3W6+3']
[r,count(length(tmpstring),''),CODE:{
[h: stringval=substring(tmpstring,roll.count,roll.count+1)]
[h,if(stringval=='W'),CODE:{
[h: wuerfelanzahl=substring(tmpstring,0,roll.count)]
[h: wuerfelarts=roll.count+1]
}]
[r,if(stringval=='+'),CODE:{
[r: cpass=roll.count]
};
{}]
}]
I used this code for it and it worked out for the part that is before 'W'. If i try to use the same way to get the part between the 'W' and the '+', i am getting an error. Thats why i tried to get the actual countposition via roll.count, when the '+' is found. that should be 3 but the reply is always 1 (even if i change the string and add numbers before it for example '123W6+3'). Does anybody know why i get the wrong reply or how i am able to avoid it?