Ask confuses me

I'm trying to figure out the ask a question script, for example i enter:
ask a question
do you want an apple or an orange?
apple=true
orange=false
but no matter what the option i set as true is always the one it uses, even if i click on NO, any help would be appreciated


nevermind, allot of trial and error solved the problem


the 'ask/Ask' Function/Script is a bit confusing, in what it actually is doing

it's for a 'yes/no' type of question

it displays the more user-friendly 'yes/no' choices/options, but it's actually (and automatically: hidden from you) storing Boolean Values ('true/false') into the built-in 'result' Variable VARIABLE:

select 'yes'---> result = true
select 'no' ---> result = false

ask ("Accept?") {
  //
  // result = YOUR_SELECTED_CHOICE/OPTION:
  //
  // if selected 'yes', then: result = true
  // or
  // if selected 'no', then: result = false
  //
  if (result) {
    msg ("YES/TRUE")
  } else {
    msg ("NO/FALSE")
  }
}

---------

ask ("Accept?") {
  if (not result) {
    msg ("NO/FALSE")
  } else {
    msg ("YES/TRUE")
  }
}

Truth/Logic/Boolean Tables:

Definition:

true -> TRUE
false -> FALSE

Negation ('NOT'):

not true -> FALSE
not false -> TRUE

Conjugation ('AND'):

true and true -> TRUE
true and false -> FALSE
false and true -> FALSE
false and false -> FALSE

Disjunction ('OR'):

true or true -> TRUE
true or false -> TRUE
false or true -> TRUE
false or false -> FALSE


if you want a normal open-ended question, there's the built-in 'show menu / ShowMenu' Scripts/Functions:

it automatically (hidden from you) stores your selected choice/option into the built-in 'result' Variable VARIABLE

create ("example_object")

example_object.sex_stringlist_attribute = NewStringList ()

list add (example_object.sex_stringlist_attribute, "male")
list add (example_object.sex_stringlist_attribute, "female")

show menu ("Sex?", example_object.sex_stringlist_attribute, false) {
  //
  // result = YOUR_SELECTED_CHOICE/OPTION:
  //
  // result = "male"
  // or
  // result = "female"
  //
  player.sex_string_attribute = result
}

Log in to post a reply.

Support

Forums