I need help with some *if and variables
Basically what i have is
#Coffee seems like the only fuel you can consume here, I'll take it.
*temp var "Coffee"
*goto intro
#Tea helps me calm down, I'll have a cup of it.
*temp var "Tea"
*goto intro
#Water. Need to be hydrated.
*goto intro
*temp var "Water"
#Nothing really.
*temp var "Nothing"
*goto intro
And then i later on i have:
*if var = "Coffee"
Coffee has come.
*goto questions
*if var = "Tea"
Tea has come.
*goto questions
*if var = "Water"
Water has come.
*goto questions
*if var = "Nothing"
Nothing has come.
*goto questions
But when i test it out it appears an error like āinvalid indent, expected at least one line in āifā true blockā
Can someone help me out?
You can do this:
*choice
#Coffee seems like the only fuel you can consume here, I'll take it.
Coffee has come.
*goto questions
#Tea helps me calm down, I'll have a cup of it.
Tea has come.
*goto questions
#Water. Need to be hydrated.
Water has come.
*goto questions
#Nothing really.
Nothing has come.
*goto questions
If you could copy the entire context of this bit, we could help further. but in short:
*temp
is a command if you need a variable only for one scene.
For example:
*temp drink ""
What do you want to drink?
*choice
#Coffee seems like the only fuel you can consume here, I'll take it.
*set drink "coffee"
*goto questions
#Tea helps me calm down, I'll have a cup of it.
*set drink "tea"
*goto questions
#Water. Need to be hydrated.
*set drink "water"
*goto questions
#Nothing really.
*set drink "nothing"
*goto questions
*label questions
@{(drink = "nothing") You don't drink anything.| You drink ${drink}.}
The bit with the @ is multireplace, allowing to have multiple variants of a sentence without doing *if
Okay iāll try it!
I feel like the second one might work better because in the middle of choosing a drink and getting the drink there is a scene that takes place. But i think i know how to fix it now.
Thank you!
It depends:
does the drink come up at another time in the same scene?
If not you donāt need to make it a variable.
Yes it does. And the attitude of the character also changes depending on the drink.
Ahh. alright. Yeah, then the second works better probably. You could also combine things like this:
*temp drink ""
What do you want to drink?
*choice
#Coffee seems like the only fuel you can consume here, I'll take it.
You drink coffee.
*set drink "coffee"
*goto questions
#Tea helps me calm down, I'll have a cup of it.
You drink tea.
*set drink "tea"
*goto questions
#Water. Need to be hydrated.
You drink water.
*set drink "water"
*goto questions
#Nothing really.
You drink nothing.
*set drink "nothing"
*goto questions
*label questions
Yeah okay, thank you so much for the help!
I think i managed thanks to you, iāll update this if i keep having problems.
Okay having the same message though i still donāt know why.
My code is this:
*if drink = "coffee"
You take a sip from your coffee.
*goto questions
*if drink = "tea"
You take a sip from your tea.
*goto questions
*if drink = "water"
You take a gulp from your water.
*goto questions
*if drink = "nothing"
You stand there.
*label questions
But when the drink is coffee it works well, but the rest of the drinks it goes into the same error.
It might be that you need an indentation after every *if line? I canāt tell if itās just that itās hard to indent on the forum or if you arenāt indenting in the code. I can see you have indentations on the first block of code example you put in, but not the second.
No i understood you.
And i did it.
It actually worked!
Thank you for the help!
Iāll keep updating if i have more problems.
you donāt need and *if statement in this case.
*if and its siblings are more for stuff like this:
*choice
#game1
*if (rival = "Walter")
You should be aware that this is the game that will have you face Walter.
*goto game1
*else
At least you won't face your rival in this.
*goto game1
#game2
*if (rival = "Hank")
You should be aware that this is the game that will have you face Hank.
*goto game1
*else
At least you won't face your rival in this.
*goto game1
etc
Oooooh
Sorry, since iām kind of new to this.
But i get what you mean. Thank you for the help!
No worries
Oh, also thereās
*elseif
goes like this:
*if (possibility 1)
stuff
*goto more
*elseif (possibility 2)
stuff
*goto more
*else
stuff
*goto more
*else covers the variables not used for if/elseif in that body
That might be useful later on.
Thank you once again!
Okay one more problem.
Iām sorry for being such an amateur about this.
*if drink = "tea"
You sip the tea.
*goto questions
*if drink = "water"
You sip the water.
*goto questions
Now the tea works well and all, but the water one doesnāt show the āyou sip the waterā part. It just goes to the label questions.
Try this:
*if drink = "tea"
You sip the tea.
*goto questions
*elseif drink = "water"
You sip the water.
*goto questions
*elseif drink = "coffee"
You sip the tea.
*goto questions
*else
You drink nothing.
*goto questions
But as said, having an if/elseif/else seems unnecessary here from what I can see.
*choice
#Coffee seems like the only fuel you can consume here, I'll take it.
You drink coffee.
*set drink "coffee"
*goto questions
#Tea helps me calm down, I'll have a cup of it.
You drink tea.
*set drink "tea"
*goto questions
#Water. Need to be hydrated.
You drink water.
*set drink "water"
*goto questions
#Nothing really.
You drink nothing.
*set drink "nothing"
*goto questions
will do the trick at this bit as well.
if/elseif/else should only come into play once the text differs greatly further down the line.
like
*if ((drink = "tea") or (drink = "coffee"))
You spill the ${drink} over Hank. He screams. Bloody Hell that must have been hot.
*goto whoops
*elseif (drink = "water")
You spill the ${water} over Hank. Whoops.
*goto whoops
*else
*goto nowhoops
*if drink = "coffee"
You drink the coffee.
*goto questions
*elseif drink = "tea"
You sip the tea.
*goto questions
*elseif drink = "water"
You sip the water.
*goto questions
*else
You stand there.
*goto questions
Thatās what i put. But now if i choose water, it shows the ānothingā result.
ah bother, my mistake.
add () around the variables. like
*if (drink = āwaterā)