*if and true/false variables ! PLEASE HELP

Okay, so I’ve done boolean variables before with past games and it’s worked, and I’ve triple checked my code this time. I’m not really sure what I’m missing. Can someone please help?

It’ll be much easier to explain with a visual, so here are some pics I took of my laptop, on the desktop app version of CSIDE:

IMG_1583|667x500

So here is what the code looks like at the beginning when I created the variables. ^

IMG_1587 (1)|374x500

^ Here is when I set the variables. It’s the first choice in the novel and establishes the MC’s feelings towards a situation for the rest of the game.

THIS IS WHERE THE ISSUE STEMS FROM. I chose the second option in testing, the one that sets society_angry as true.

IMG_1585|375x500

^ Here is where I implemented the “if” command, to personalize how the MC reacts based on their feelings established in the first choice.

IMG_1588|690x283

^ And here is what happens when I run the project. According to choicescript there are no errors, but when I chose the option that’s supposed to set society_angry to true, it shows the dialogue that’s meant for the (society_excited true) variable. No matter which option I choose in the first choice to change the boolean variable, it always displays the society_excited one. I assume this is because it’s the first *if command in code, though I don’t know why it’s not registering the other variables.

I wondered if it’s because I don’t include a “false” variable, though I don’t see how I could make one work in this scenario. There is no way the variable could be false, there’s only other feelings set to true that the MC could experience.

I have been trying to figure this out for days. I’m fairly new to choicescript, so I have been researching relentlessly trying to find what I’m doing wrong, but I can’t figure it out.

Please let me know if this is in anyway confusing, as I would love to explain it further. Whatever it takes to fix this, please!!

given the var1, 2 and 3 being true:

*if var1 true
  one
*if var2 true
  two
*if var3 true
  three

output= one two three

*if var1 true
  one
*if var2 false
  two
*if var3 true
  three

output= one three

*if var1 true
  one
*elseif var2 true
  two
*else var3 true
  three

output= one

*if var1 false
  one
*elseif var2 true
  two
*else var3 true
  three

output= two

So,
*if
*if
*if
will check each and every *if and combine the result in order.

*if
*elseif
*else
Will check one by one and only give you the first one that’s checked.

You can hit the key print screen on your keyboard and paste in paint or some image editor to make a snapshot of what you are seeing on your monitor, no need to take real pictures of your screen.

3 Likes

I notice you set all the variables as true with the *create command.

Are they set to false at any point?

3 Likes

I think the problem is that, during the *create process in your first pic, you set EVERY society_variable as true. Then later, the choice that determines which one should be true isn’t changing anything - it’s taking one value (e.g. society_angry) and setting it true, when they’re already all true. Then during the section that’s supposed to show which variable is true, it picks the excited option, because that’s the first one in line and it’s already set to be true, regardless of the choice.

Like @Nocturnal_Stillness said, it might be worth trying to *create them all as false initially and see if that solves the problem. Think of it as less true/false and more like on/off - you need them all to start in the off position, so that the *choice can later choose which one to turn on, if that makes any sense.

2 Likes

OH MY GOD IT WORKED!!! Thank you so much, you don’t know how many times I’ve tried different things to see which one would work. You explained it in a way that was easy to understand, with the on/off comparison that makes sense, so I appreciate it!

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.