Help with muliple if statments

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
Idward
Kobold
Posts: 20
Joined: Sat Dec 08, 2012 8:11 pm

Help with muliple if statments

Post 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]
}]

User avatar
aliasmask
Deity
Posts: 8625
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Help with muliple if statments

Post 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.

Idward
Kobold
Posts: 20
Joined: Sat Dec 08, 2012 8:11 pm

Re: Help with muliple if statments

Post 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.

Post Reply

Return to “Macros”