Question script help

I have an amp ask the player a yes/no question and written out responses but its giving me the same error when I test it

Here's what I have:

Npc dialoge

  • ask question
  • after choosing run script
    -- If expression result = No
    -- response from npc as msg
    -- else if expression result = Yes
    -- response from npc as msg

Online quest - what do I do to clear this up? Did I type in the expressions wrong?


If you're using the "ask" or "Ask" function,. then the expression for the if statement should just be result, and the expression for the else if should be not result (or just use "else" rather than "else if"). In this case, you're testing if the result from the question is true or not true.

If you're using the "show menu" or "ShowMenu" function with the options "Yes" and "No", the expression for the if statement should be result = "Yes" and the expression for the else if statement should be result = "No". In this case you're comparing the result of the question to the string "Yes" or the string "No". The quotes are necessary to tell Quest that Yes is a string of text, not the name of an object.


Ok. Only name result if using menu script...thanks


I think quest automatically converts your 'ask/Ask' menu Function's selection of 'yes/no' into 'true/false':

yes -> true -> result = true
// or:
no -> false -> result = false

so, it should be:

if you select 'yes' for the menu selection:

yes -> true
result = true

if you select 'no' for the menu selection:

no -> false
result = false

and then conceptually, its:

[result = either true or false, based upon what you selected]

if (result = true) {
  // blah scripting
} else if (result = false) {
  // blah scripting
}

and how it conceptually works:

if ( [result = true] = true ) { // if ( [true] = true )
  // blah scripting
} else if ( [result = false] = false ) { // if ( [false] = false )
  // blah scripting
}

but, the scripting is optimized into this shortened form (quest understands it as the same as the above):

if (result) {
  // blah scripting
} else {
  // blah scripting
}

and in the GUI/Editor, it'd look like this:

if [EXPRESSION] result
-> then -> add new script -> blah script
else
-> then -> add new script -> blah script

if you're using 'show menu / ShowMenu', it'd be:

show menu ("YOUR_DISPLAYED_MENU_QUESTION_PROMPT", Split ("yes;no", ";"), false) {
  //
  // quest automatically will set:
  //
  // result = "yes"
  // or:
  // result = "no"
  //
  if (result = "yes") {
    // blah script
  else if (result = "no") {
    // blah script
  }
}

since we're using 'yes/no' as our menu selection choices/options/items/values, this 'show menu / ShowMenu' example, is basically what the built-in 'ask/Ask' Function is doing above

however, we can of course use different menu selection choices/options/items/values, for example:

show menu ("Sex?", Split ("male;female;hermaphrodite;asexual", ";"), false) {
  //
  // quest automatically will set:
  //
  // result = "male"
  // or:
  // result = "female"
  // or:
  // result = "hermaphrodite"
  // or:
  // result = "asexual"
  //
  if (result = "male") {
    player.sex = "male"
  else if (result = "female") {
    player.sex = "female"
  } else if (result = "hermaphrodite") {
    player.sex = "hermaphrodite"
  } else if (result = "asexual") {
    player.sex = "asexual"
  }
}

Data Types: VARIABLE TYPES (Variable Types / Attribute Types / Parameter Types) and their Value Types:


Strings ("text"): a collection of alphabetic characters, numeric (number) characters, and/or the other symbols/characters

anything within the double quotes, is a String Value, some examples:

"a"

"abc"

"1" // this is NOT an amount (integer: a non-decimal number or double: a decimal number, and also known as floating-points /
fractional numbers / decimal numbers --- but quest uses the term, 'double', for it) value, you can NOT do arithmetic with it, as it's a String Value

"123" // same as above

"abc123"

"abc_123"

"abc 123" // "abc[SPACE]123"

" " // "[SPACE]" --- yes, a 'SPACE' is a character/symbol too

"Welcome to my game, I hope you enjoy it!"

"true" // this is NOT a boolean value, as it's within the double quotes, making it a String Value

"false" // this is NOT a boolean value, as it's within the double quotes, making it a String Value

String Variable example:

alias = "HK"

String Attribute example:

player.alias = "HK"
// 'player' must be an actual existing Object of course


Booleans:

are the special/reserved values of 'true/false'

notice that 'true/false' do NOT have the double quotes, as if they did, they'd be String Values, and NOT Boolean Values

Boolean Variable:

dead = true // conceptually whatever (or the current state) is 'dead'
// or:
dead = false // conceptually whatever (or the current state) is 'alive'

alive = true // conceptually whatever (or the current state) is 'alive'
// or:
alive = false // conceptually whatever (or the current state) is 'dead'

Boolean Attribute:

// 'orc' must be an actual existing Object, of course

orc.dead = true // conceptually the 'orc' (or its current state) is 'dead'
// or:
orc.dead = false // conceptually the 'orc' (or its current state) is 'alive'

orc.alive = true // conceptually the 'orc' (or its current state) is 'alive'
// or:
orc.alive = false // conceptually the 'orc' (or its current state) is 'dead'

underneath, Boolean Values are converted into binary:

true -> 1
false -> 0

but the concept remains the same: dualism (opposites): 2 states:

true = 1 = "yes" = "on" = "+ (positive, like with electrical charges)"
vs
false = 0 = "no" = "off" = "- (negative, like with electrical charges)"

positive vs negative
up vs down
in vs out
left vs right
forward vs backward
hot vs cold
smart vs stupid
tall vs short
male vs female
fat vs skinny
good vs evil
etc etc etc

in networking (and low programming languages and at the hardware level itself as electrical currents), binary is used as 'flags' (which is why Booleans/binary and 'flags' are often used interchangably --- though I don't personally like using 'flags' in this manner):

something is "flagged on" or something is "flagged off", or think of 'flagging' as like a light switch, that is flipped on or flipped off

Boolean is merely the human friendly usage of 'true/false' terms/words, instead of the non-programmer non-friendly usage of binary's digits of '1/0'


Amounts:

able to do arithmetic (additional, subtraction, multiplication, division, and modulus) upon them

anything that is a number amount and NOT within double quotes, is either:

Integers (non-decimal numbers):

-999
0
999

strength = 100

player.strength = 100

Doubles (Floats / Floating Points) (decimal numbers):

-999.12345678, 0.0, 999.123

damage = 56.3

player.damage = 56.3


Objects (references/pointers):

anything NOT within double quotes, anything that is NOT an amount (a number), and anything NOT as a reserved/special word/term, is an Object (reference/pointer), some examples:

(all of these have to be actual existing/created Objects, of course)

game
player
room
orc
dragon
sword


so, that's what gets many people confused with scripting, especially conditional expressions:

there's a big difference between:

if (result = "sword") { /* scripting */ }
// and:
if (result = sword) { /* scripting */ }

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

switch (result) {
  case ("sword") {
    // scripting
  }
}

// and:

switch (result) {
  case (sword) {
    // scripting
  }
}

---------

using a String List or String Dictionary
vs
using an Object List or Object Dictionary

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

Support

Forums