How to use ASK QUESTION

I'm lookin' at the ask question box that the GUI editor gives you, but it's not making sense.
I wanna ask the player a question, in the middle of a script, where answering yes or no will change the outcome.

I want to make it so that it could run two different scripts, one for yes, and one for no. But it only allows you to run a single script regardless of what answer they pick. How does that even help? What is the point of the Ask question script when used this way?

I know I've seen people do what I am attempting, so I just need to know how.

Thanks for any help.


well, you got the first step right:

understanding that the 'ask/Ask' Function/Script is a 'yes/no' type of question, and not a normal open-ended question (use the 'show menu' or 'ShowMenu' for normal open-ended questions)


'ask/Ask' provides the person/user/player with the selection of 'yes/no', however, in the actual code, the selection is (automatically: hidden from you) stored within the 'result' Variable VARIABLE as 'false/true'

if you select the 'yes' choice/option: result = true // the 'true' Boolean Value is stored into the 'result' Variable VARIABLE
if you select the 'no' choice/option: result = false // the 'false' Boolean Value is stored into the 'result' Variable VARIABLE

so, within the 'ask/Ask' Script/Function, you need an 'if' Script, to handle the conditional (result = true / result = false), so you can have two different responses/actions, based on whether the person/user/player chose 'no' or 'yes'

as in-code scripting, it's long form (NOT efficient: does extra operations that it doesn't need to do, as quest has been programmed to understand a shortened form allowing it to skip those extra operations) looks like this, an example

ask ("Do you want to keep playing?") {

  // quest automatically (hidden from you) stores your choice, as 'true/false' within the built-in 'result' Variable VARIABLE:
  //
  // if chose 'yes', then: result = true
  // or
  // if chose 'no', then: result = false

  if (result = true) {
    msg ("You chose to keep playing")
  } else if (result = false) {
    msg ("You chose to quit")
  }

}

conceptually, how the use of the 'if' Script/Function above (in this case/usage/scenerio/example) works:

// result = true

if (result = true) {
// if ( [result = true] = true) {
// if [ [true] = true) {
// (yes, 'true' = 'true') -> TRUE
// if (TRUE), then do its nested script below
  msg ("You chose to keep playing")
} else if (result = false) {
  msg ("You chose to quit")
}

// output:

You chose to keep playing

----------------------------------------------------

// result = false

if (result = true) {
// if ( [result = false] = true) {
// if [ [false] = true) {
// (no, 'false' is NOT = to 'true') -> FALSE
// if (FALSE), skip its nested script below, and jump to the next code/script line instead
  msg ("You chose to keep playing")
} else if (result = false) {
// else if ( [ result = false] = false) {
// else if ( [false] = false) {
// (yes, 'false' = 'false') -> TRUE
// if (TRUE), then do its nested script line below
  msg ("You chose to quit")
}

// output:

You chose to quit

now, quest is programmed to understand a shortened form with Boolean (false/true) usage, along with using 'else' for a binary/opposite conditional choice/option, both of which, are more efficient code-wise: less operations that it has to do/perform):

if (BOOLEAN) {
// if (BOOLEAN = true) {
  // WHATEVER scripting
} else {
// if (BOOLEAN = false) {
  // WHATEVER scripting
}

// or (reversing it, via using Negation: the 'not' logic operator)

if (not BOOLEAN) {
// if (not true)
// if (BOOLEAN = false) {
  // WHATEVER scripting
} else {
// if (true)
// if (BOOLEAN = true) {
  // WHATEVER scripting
}

so, here's the shortened form of the example in this post:

this IS the type of form/pattern/syntax that you want to do (though you'd need to adjust it for your own application within your game, as this is just an example)

and the next section below this section, shows how to do this example through the GUI/Editor, as you probably aren't a coder yet, wink

ask ("Do you want to keep playing?") {

  if (result) {
    msg ("You chose to keep playing")
  } else {
    msg ("You chose to quit")
  }

}

// or:

ask ("Do you want to keep playing?") {

  if (not result) {
    msg ("You chose to quit")
  } else {
    msg ("You chose to keep playing")
  }

}

so, to do the 'if' Script in the GUI/Editor for within the 'ask/Ask' Function/Script:

within the 'ask/Ask' Function/Script:

[run as a script] -> add new script -> 'script' section/category -> 'if' Script -> (see below)

if [EXPRESSION] result

-> then -> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "You chose to keep playing"

else

-> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "You chose to quit"

// ---------------------------------------

// or:

within the 'ask/Ask' Function/Script:

[run as a script] -> add new script -> 'script' section/category -> 'if' Script -> (see below)

if [EXPRESSION] not result

-> then -> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "You chose to quit"

else

-> then -> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "You chose keep playing"

lastly, about the 'ask' vs 'Ask' Scripts/Functions:

any built-in Script/Function that has lower-case and upper-case versions:

the lower-case version does the pop-up window menu selection

the upper-case version does the in-line (the blue hyperlink text) menu selection

'ask' vs 'Ask'

'show menu' vs 'ShowMenu'

and probably more that I can't think of right now


I’ve always understood switch/add cases better than ask question. So, I have “mastered the art” of putting in big bold letters, maybe after a “wait for key press” script, a questions like:

Are you sure you want to continue reading this crap?

At which point I would use a switch script to respond to “yes” or “no” (or variants of that) and I would add a else script to loop the question back again until I got a yes or no answer that would make the game proceed.


Almost forgot to thank hegemonkhan for their help. This information was very useful.

So useful I immediately got to work and forgot!

Cheers mate!


Log in to post a reply.

Support

Forums