What is wrong with this piece of code? My guess is that it's an indentation error but I can't figure out what is wrong and where I've done the mistake

*choice 
 #Straight
   *set sexual_orientation "Straight"
*if (gender) = "Male"
   *set partner_name "Emily"
   *set partner_gender "Female"
   *goto afterchoosingstraightsexualorientation
*elseif (gender) = "Female"
   *set partner_name "Armand"
   *set partner_gender "Male"
   *goto afterchoosingstraightsexualorientation
 #Gay
   *set sexual_orientation "Gay"
*if (sexual_orientation) = "Gay"
   *set partner_name "Armand"
   *set partner_gender "Male"
   *goto afterchoosinggaysexualorientation
 #Lesbian
   *set sexual_orientation "Lesbian"
*elseif (sexual_orientation) = "Lesbian"
   *set partner_name "Emily"
   *set partner_gender "Female"
   *goto afterchoosinglesbiansexualorientation
 #Bisexual
   *set sexual_orientation "Bisexual"
   *goto afterchoosingbisexualsexualorientation
*label afterchoosingbisexualsexualorientation
Your current partner is a…
*choice 
 #Male 
  *set partner_name "Armand"
  *set partner_gender "Male"
  *goto afterchoosingbisexualpartnergender
 #Female
  *set partner_name "Emily"
  *set partner_gender "Female"
  *goto afterchoosingbisexualpartnergender
*label afterchoosingstraightsexualorientation
*label afterchoosinggaysexualorientation
*label afterchoosinglesbiansexualorientation
*label afterchoosingbisexualpartnergender```

Hey all.The problem is that I'm getting only the "straight" option displayed.Noting that, this is most likely an indentation mistake but I can't figure out what have I done wrong and where.Any help would be greatly appreciated.Thanks in advance, for any help you may provide.

-Mephisto

Please use the ` character to show your code, otherwise we can’t see the indentation.
You can use three at the beginning and three at the end to form a block like this:

your code

image

2 Likes

Using the </> symbol on a highlighted section of text when you’re composing a post should do the same. Then we can see your indentation…

1 Like

Done! Thank you.I had forgotten it doesn’t do it automatically.

The if/elseif after your first choice aren’t indented, so they’re cutting off everything that comes after them…

They should be at the same indent level as set sexual_orientation.

1 Like
*choice 
  #Straight
    *set sexual_orientation "Straight"
    *if (gender) = "Male"
      *set partner_name "Emily"
      *set partner_gender "Female"
      *goto afterchoosingstraightsexualorientation
    *elseif (gender) = "Female"
      *set partner_name "Armand"
      *set partner_gender "Male"
      *goto afterchoosingstraightsexualorientation
  #Gay
    *set sexual_orientation "Gay"
    *if (sexual_orientation) = "Gay"
      *set partner_name "Armand"
      *set partner_gender "Male"
      *goto afterchoosinggaysexualorientation
  #Lesbian
    *set sexual_orientation "Lesbian"
    *elseif (sexual_orientation) = "Lesbian"
      *set partner_name "Emily"
      *set partner_gender "Female"
      *goto afterchoosinglesbiansexualorientation
  #Bisexual
    *set sexual_orientation "Bisexual"
    *goto afterchoosingbisexualsexualorientation
*label afterchoosingbisexualsexualorientation
Your current partner is a…
*choice 
  #Male 
    *set partner_name "Armand"
    *set partner_gender "Male"
    *goto afterchoosingbisexualpartnergender
  #Female
    *set partner_name "Emily"
    *set partner_gender "Female"
    *goto afterchoosingbisexualpartnergender
*label afterchoosingstraightsexualorientation
*label afterchoosinggaysexualorientation
*label afterchoosinglesbiansexualorientation
*label afterchoosingbisexualpartnergender```

This would be the correct indentation, though you have other problems with the if/else commands

I suggest you to take a look at this post.

2 Likes

This did the trick! I was so frustrated! Thank you Joel! Seems like I got an example by the wiki mixed up on my head and messed up with the indent.I shall be more careful.

Oh? When I test the game on CSIDE it doesn’t throw any errors regarding the if/else…

1 Like

It should jump on the quicktest. The if/else needs to be used in its own block, you can’t split it with a choice in between.

Wrong

*choice
  #A
    *if x = 1
      something something
      *goto whatever
  #B
    *elseif x = 2
      something more
      *goto whatever

Right

*choice
  #A
    *if x = 1
      something something
      *goto whatever
    *else
      Other something
      *goto whatever_else
  #B
    *if x = 2
      something more
      *goto whatever
    *elseif x = 3
      Something elseif
      *goto whatever_else_if
    *else
      Other whatever else
      *goto whatever_other_else

The if/else block needs to be on the same line of indentation, and you have to finish it with an *else. If not, you aren’t telling the program what to do if that check isn’t true, no matter if it never happens, quicktest would tell you you have to, it’s a good practice to do it anyways, to avoid bugs and errors you’ll have to correct later on.
You can learn a lot more on the documentation I showed you, there’s a lot of useful info there.

1 Like