Help With If/Elif/Else!


#1

Hi! I’m currently coding a personality quiz using the points system and I’m in a bit of trouble.

There are 18 questions and there are five categories: Air, Water, Fire, Earth, and Metal. There are different charcters for each one and every time the reader chooses and answer that corresponds with that element that character recieves a point.

At the end I used the coding:
if (AIR > FIRE and METAL and WATER and EARTH){
goto airresult
}
and then the same thing with the other results. The issue is that no matter what the air result always comes up! Even when I select only fire or water answers the air result is the only thing I get. I’ve tried using gains and labels and anything I can think of. Any ideas on what to do?


#2

You should reset story progress.


#3

Do you mean on mobile? I’ve done that multiple times already. Do I just have a broken script?


#4

What does your if/elif/else look like?


#5

I don’t know if it matters but maybe AND should be in capitals and also after the if brackets end, you should have an else or elif.
Where did you see that order though (AIR>FIRE AND …)? Is it on the guides?


#6

I saw it on a thread about using point systems. The chapter ended up saving so I assume it’s legit.


#9

It seems like that method no longer works anymore :frowning_face: It now only works comparing points between only 2 characters. BUMMER.


#10

What if you try something like
If (AIR> METAL AND AIR>FIRE AND AIR>WATER AND AIR>EARTH) {
} elif …
Idk if it fixes it but yeah


#11

Yeah, I think I’ll do something like that. Maybe with gotos anf labels and stuff. @A.V


#12

I created this for you, hope it helps!

EDIT: SO SORRY! I just realized that it will be a lot more complicated than that code ARGH


#13

It’s fine! I tried that and a slightly modified version of what A.V. suggested, but neither of them worked! WHY IS EVERYTHING SO CONFUSING I JUST WANT A NICE LITTLE QUIZ THAT WORKS


#15

If it helps, I’ve done some math and the highest number you can get is 5. So if you want to use some gotos, it might work. For example:

if (AIR > 4) {
goto AIR

} elif (METAL > 4) {

goto METAL

} elif (WATER > 4) {

goto WATER

} elif (EARTH > 4) {

goto EARTH

} else {

goto FIRE

}

And there can only be up to three 5s in the outcome. So if you have to do a tie-breaker, you’d have to chose which element they’d get. Put that one first.


#16

What’d ya think @Dara.Amarie
Am I completely off the mark :see_no_evil:


#17

Continuing the discussion from Help With If/Elif/Else!:

@RudeInception I just tried this! It unfortunately didn’t work. I figured out that the result immediately goes to the first elif choice (as in the first choice resulting in one element having the highest points). I figured this out because I switched the position of elif (FIRE > 4) and elif (AIR > 4). I think your coding would work great, but now the issue seems to be getting the points to actually register. Any ideas?


#18

@Dara.Amarie Can you help here? :heart:


#19

The points do register but like I said, three elements can get 5 points each. So when that happens the choice will go to the first option. If the reader makes choices that give them higher than 5 points for an element, then that’ll be the element given to them.


#20

This can be closed as I figured it out myself. Just published it in Episode 6 of Elemental and it’s live on the platform. Thank you so much @night_owls for trying to help!!! :hugs:


#21

Closing due to one month of inactivity :slight_smile:


#22