Hey, guys. I’m working on a game for my friends, and I’m having trouble trying to get *else text to appear. This problem does not show in my other txt files, so I’m curious as to why it’s happening now.
*if statements work just fine, however, the else statement shows nothing. The text in question:
You leave the fry shop,
*if (fries = true)
snacking on the delicious fries as you walk across the boardwalk.
*goto aftervisit
*else
feeling as if you haven't done anything.
*goto aftervisit
If fries = true, the text below it appears. However, the else statement doesn’t, and it just shows the first part of the text before the *if statement.
I’ve tried using *elseif (fries = false) instead of *else, but that doesn’t work either.
And in case this is important, the fries variable is set under *temp in that same scene file.
Can anyone tell me what I’m doing wrong?
The *goto on line 4 needs to be indented else it just skips the else statement
That fixed the problem perfectly. Thank you for your help!
You can use
*if (fries = false)
instead of *else or *elseif. *else is helpful for when you have numerical variables that you want to express across more than two options, but for true/false statements, I have found that *if is cleanest and is easier to keep track of.
Also, if the *goto source is the same, you only need it once at the end (if they were different depending on whether the stat is true or false, then you’d need to indent it anyway, or maybe you did and it just didn’t translate after copy and paste).
I hope that makes sense and helps!
Edit: Haha, nevermind, I see someone else helped you out first!
Use of “else” at the end of a string of "if"s is also often required for a game to pass quicktest – something to keep in mind as you code if you want CoG to consider it for publication.
2 Likes