[SOLVED] Asking Yes/No questions on Quest online

adt94
Hi all,

I'm at the end of writing a game where lying down on your bed causes the session to end. I've given warning about this to the player prior, but I also want them to be able to select "yes/no" when asked "Are you sure?" I've got everything else working but I can't seem to figure this out.

I'm using Quest online on my Mac, and tried "run script > ask question > Are you sure you would like to lie down?" This throws up the options 1. Yes 2. No. So far, so good.

But I can't get it to work after this point. I tried "if expression: 1", "if expression: yes", etc., but it kept giving me an Int32 error. Clicking the hyperlinks in-game caused the same problem. I checked the Quest documentation and it said to use "if expression: true". When I tried that, the error message disappeared, but regardless of whether the player clicked 1 or 2, it gave the same response.

So, to clarify: I want "Are you sure?" "Yes" "Game over"/ "Are you sure?" "No" "Undo turn". What I have is this:

Ask ("Are you sure you would like to lie down? You are sure to fall asleep; and by the atmosphere of a lucid dream about this place, there is no guarantee you'll ever find it again.") {
if (true) {
finish
msg ("You fall asleep.")
}
else if (false) {
undo
}
}


And it will not differentiate between responses. It ends the game regardless to yes or no, or it undoes a turn regardless of yes or no, depending on whether I open with "if: true" or "if: false".

How do I get the game to recognise whether the player answers yes or no, instead of ignoring their input entirely or throwing up an error? I used another yes/no question earlier in the game and I'm having the same problem.

Thank you very much in advance. Sorry if this doesn't make much sense; I'm writing while at the end of my tether! I'm ready for beta apart from this one issue...

Edit: Also, I'm very new to this, so apologies if this is a silly question.
Edit 2: I'm happy to discuss workarounds for this, but if it would be better in IF Answers that's fine. I should also clarify I've tried simply "else" as well as "else if (false)". Just not sure why the else keeps getting overridden.

TinFoilMkIV
for the 'Ask' function, the game creates a variable called 'result' where it saves your input. You can use this to pull the response for your if/else function.

It should look something like this

Ask ("Are you sure you would like to lie down? You are sure to fall asleep; and by the atmosphere of a lucid dream about this place, there is no guarantee you'll ever find it again.") {
if(result){
msg("You fall asleep.")
esle{
undo
}
}

Selecting 'Yes' sets result to true, and 'No' sets it to false, but you don't need an ifelse(false) because if it's not true, then it has to be false. Also in the case of result somehow not being either true or false, it still defaults to not ending the game, which in this case is probably desirable.


The problem with your code is you weren't checking a variable, you were just asking the game "is true = true?" which is always the case so it always goes with your first block of code. What you wanted to ask is "is the players answer = yes?". The part you missed was actually referencing the players answer.

adt94
Thanks so much, TinFoil. I'll go and try that now.

Edit: It's worked, of course. You're a lifesaver. I was too stressed out to have ever figured that out.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums