Page 1 of 1

Help with muliple if statments

Posted: Sun Nov 29, 2015 10:31 am
by Idward
I am having a problem trying to get my If statements to run properly.

Code: Select all

[h: encounter = 1d100]
[h: chatOutput=If(encounter >= 92 && encounter <= 99, "will-o’-wisp"+timeOutput, chatOutput)]
The Error message I am getting is:
Statement options (if any): h Statement Body : chatOutput=If(encounter >= 92 && encounter = 99, "will o’-wisp"+timeOutput, chatOutput)

I am able to get it to work if I remove the and section of the code.


Full code:

Code: Select all

[h: success=1d100]
[h: encounter = 1d100]
[h: chatOutput = ""]
[h: timeOutput= ""]
[h: time=1d4]

[if(success >= 20), code:{No combat.};{Combat! <br>

[h, switch(time), code:
case 1: {[timeOutput = " after you just set out from camp"]};
case 2: {[timeOutput = " durring the middle of the day"]};
case 3: {[timeOutput = " after you set camp"]};
case 4: {[timeOutput = " in the middle of the night"]};
default: {[timeOutput = "broken"]}
]

[h: chatOutput=If(encounter >= 1 && encounter <= 10, 1d6+" dire rat(s)"+timeOutput, chatOutput)]
[h: chatOutput=If(encounter >= 11 && encounter <= 20, 2d4+" mites"+timeOutput, chatOutput)]
[h: chatOutput=If(encounter >= 21 && encounter <= 28, "dire bat"+timeOutput, chatOutput)]
[h: chatOutput=If(encounter >= 29 && encounter <= 33, 1d4+" carrionstorm(s)"+timeOutput, chatOutput)]
[h: chatOutput=If(encounter >= 34 && encounter <= 39, 2d6+" skeletons"+timeOutput, chatOutput)]
[h: chatOutput=If(encounter >= 40 && encounter <= 53, 2d6+" goblins"+timeOutput, chatOutput)]
[h: chatOutput=If(encounter >= 54 && encounter <= 62, 1d6+" goblin dogs"+timeOutput, chatOutput)]
[h: chatOutput=If(encounter >= 63 && encounter <= 74, 1d4+" rat swarm(s)"+timeOutput, chatOutput)]
[h: chatOutput=If(encounter >= 75 && encounter <= 81, 1d6+" boars"+timeOutput, chatOutput)]
[h: chatOutput=If(encounter >= 82 && encounter <= 91, 2d4+" ghouls"+timeOutput, chatOutput)]
[h: chatOutput=If(encounter >= 92 && encounter <= 99, "will-o’-wisp"+timeOutput, chatOutput)]
[h: chatOutput=If(encounter >= 100, "the Sandpoint Devil"+timeOutput, chatOutput)]
You are attacked by [r: chatOutput]
}]

Re: Help with muliple if statments

Posted: Sun Nov 29, 2015 10:38 am
by aliasmask
It's doesn't like the ' in will-o'-wisp because it's a unicode character. Change it to a standard single quote.

Also, your last line should be };{}] to the if roll option has an empty false condition. Not having it doesn't always cause problems, but it does add a ' in to the output which could effect your code and output later on. This is only needed with the if roll using "code". You don't need a false condition for a single statement.

Re: Help with muliple if statments

Posted: Sun Nov 29, 2015 1:05 pm
by Idward
Wow it seems to have just been the ' that broke it. Thank you for pointing that out. Also the If True condition is "no combat" with If False being the combat.