Noob Question: Ask A Question

So, I get how to ask a question but both Yes and No answers are displaying on click through. I’m a UI user not a coder and was wondering if anyone can enlighten me on how to do this. Sorry. I couldn’t find anything in documentation. Thanks.


Not sure what you mean. Can you show the code you're using? Then we can tell you what the problem with it is.

You can switch to code view just to copy the code so you can share it with us. Make sure to put a line with just backticks (```) above and below your code to stop the forum mangling it.


Here's the code:

Ask ("Do you have the negatives?") {
  if (Got(Negatives)) {
    msg ("Great. In you go.")
  }
  else if (not Got(Negatives)) {
    msg ("You have to have negatives to go into the darkroom.")
  }
}

Okay… so that asks the player whether they have the negatives, and then ignores what they say and allows them in (or not) based on whether there is an object named Negatives in their inventory.

I'm not quite sure why you're asking the question there. A more usual way to do that would simply be without the Ask. So:

if (Got(Negatives)) {
  msg ("Great, you have the negatives. In you go.")
}
else {
  msg ("You have to have negatives to go into the darkroom.")
}

If you want to allow the player to lie, so they can click "yes" and go in when they haven't actually got the negatives (which could make sense if there is a character guarding the door or something) you would do:

Ask ("Do you have the negatives?") {
  if (result) {
    msg ("Great. In you go.")
  }
  else {
    msg ("You have to have negatives to go into the darkroom.")
  }
}

If you want to ask the player and then check the inventory, you might want to do something like:

Ask ("Do you have the negatives?") {
  if (result) {
    if (Got(Negatives)) {
      msg ("Great. In you go.")
    }
    else {
      msg ("Don't lie. You need to find the negatives first.")
    }
  }
  else {
    msg ("You have to have negatives to go into the darkroom.")
  }
}

(Note that I used "else" rather than "else if" in these examples, because checking the same condition twice is a bad habit that shows up a lot around there. The "else" already implies "not (whatever the condition for the corresponding if statement was)")


Thank you so much. I shall try all of these approaches.


Log in to post a reply.

Support

Forums