Choice during Npc Interaction HELP

I want the player to make a choice from 2 options during a conversation with an npc, but I can't figure out show menu/get input script or even which one I should use


(filler for getting my edited post, updated/posted)
(again, filler for getting my edited post, updated/posted)
(again, filler for getting my edited post, updated/posted)


here's a really good guide for doing this in the GUI/Editor:

http://docs.textadventures.co.uk/quest/character_creation.html


if it's just a 'yes/no' type of choice/question, than you can use the built-in: 'ask/Ask' menu Functions/Scripts:

'WHATEVER' scripting Element (Verb, Command, Turnscript, Timer, etc) -> add new script -> ??? category/section -> 'probably called something like: ask a question' Script/Function

(any menu Function/Script that starts with lower-case, is a popup window menu, and any starting with a upper-case is an in-line, in the big text box as hyperlinks, menu)

ask ("Are you guilty of murdering this person?") {
  // quest automatically does: result = YOUR_CHOICE // yes -> true (result = true), no -> false (result = false)
  if (result) { // if (true)
    defendant.pleading = "guilty"
  } else { // if (false)
    defendant.pleading = "innocent"
  }
}

---------

ask ("Are you a male?") {
  // quest automatically does: result = YOUR_CHOICE // yes -> true (result = true), no -> false (result = false)
  if (result) { // if (true)
    player.sex = "male"
  } else { // if (false)
    player.sex = "female"
  }
}

if it's specific choices, than just use a normal menu Script/Function:

'show menu / ShowMenu' Script/Function

'WHATEVER' scripting Element (Verb, Command, Turnscript, Timer, etc) -> add new script -> ??? category/section -> 'probably called something like: show a menu' Script/Function

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

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

// using the 'switch' Script/Function instead of the 'if' Script/Function:

show menu ("Sex?", Split ("male;female;hermaphrodite;asexual", ";"), false) {
  // quest automatically does: result = YOUR_CHOICE
  switch (result) {
    case ("male") {
      player.sex = "male"
    }
    case ("female") {
      player.sex = "female"
    }
    case ("hermaphrodite") {
      player.sex = "hermaphrodite"
    }
    case ("asexual") {
      player.sex = "asexual"
    }
  }
}

the 'get input' Script/Function is for getting the user's typed-in input, an example:

(just using 'age', getting a typed-in number/amount input, as an example, but it doesn't have to be a number/amount input, this is just an example of one)

msg ("Age?")
get input {
  // quest automatically does: result = ToString (YOUR_TYPED_IN_INPUT)
  if (IsInt (result)) {
    age_integer_variable = ToInt (result)
    if (age_integer_variable > 12 and age_integer_variable < 50) {
      player.age_integer_attribute = age_integer_variable
    } else {
      msg ("Your age must be from 13 to 49, to play this game")
    }
  } else {
    msg ("Wrong input (type in a number next time)")
  }
}

I dont really understand that format...
I'm using the online guest if that makes any difference...


(filler for getting my edited post, updated/posted)


ah, online... I'm not familar with it... but I think you got to do it all via scripting...

going by this to help me (not sure if its accurate still): https://blog.textadventures.co.uk/2012/02/16/introducing-quest-webeditor-create-text-adventures-online-in-your-browser/

IMPORTANT: make sure that the 'simple mode' is NOT checked-in!!!! (the 'simple mode' removes most of quest's features, it is just for a super sandbox first learning of extreme basics of using quest)

an example

'game' Object -> 'Scripts' Tab -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable game.start [EXPRESSION] => { /* MASS_OF_CODE */ }

an example:

game.start => {

  // all of this below is the 'MASS_OF_CODE' that goes inside (indented) this 'start' Script Attribute of the 'game' Object (aka, as: 'game.start')

  create ("sex_object")

  sex_object.sex_stringlist_attribute = NewStringList ()
  list add (sex_object.sex_stringlist_attribute, "male")
  list add (sex_object.sex_stringlist_attribute, "female")
  list add (sex_object.sex_stringlist_attribute, "hermaphrodite")
  list add (sex_object.sex_stringlist_attribute, "asexual")

  sex_object.sex_script_attribute => {
    show menu ("Sex?", sex_object.sex_stringlist_attribute, false) {
      switch (result) {
        case ("male") {
          player.sex_string_attribute = "male"
        }
        case ("female") {
          player.sex_string_attribute = "female"
        }
        case ("hermaphrodite") {
          player.sex_string_attribute = "hermaphrodite"
        }
        case ("asexual") {
          player.sex_string_attribute = "asexual"
        }
      }
      on ready {
        msg ("Player Sex: " + player.sex_string_attribute)
      }
    }
  }

  invoke (sex_object.sex_script_attribute)

}

hmm.. in actually looking further down the link on using online quest, it does look like you got some GUI/Editor functionality to add Objects and Attributes, instead of having to do it via scripting... oh well... sorry about that...

see if you can match up the scripting of mine with doing it via the GUI/Editor stuff... but you won't likely to be able to do this... as you're new to coding (I presume/assume), so.... just wait for someone else who can help you better with doing it through the GUI/Editor... as I'd have a hard time of trying to explain and help you with it


How whould I do the first thing without code view?


How whould I do the first thing without code view?


Sorry for somehow posting that 2x, it seems I want menu then if for each of the options.... but when I go to if, I dont see an option that refers to the menu.


How whould I do the first thing without code view? (CheshireTiger)

do you mean creating the Stringlist Attribute (which will hold the string values, which will be used by the menu for its choices/options)?

does, the online version have the 'Attributes' Tab for its Objects? (see below)

'WHATEVER' Object -> 'Attributes' Tab -> 3 boxes (the bottom box is the 'Attributes' box for adding Attributes) -> Add -> (see below)

(Object Name: WHATEVER, example: sex_object)
Attribute Name: WHATEVER, example: sex_stringlist_attribute
Attribute Type: stringlist
Attribute Value: (hopefully, this has options/controls to now add in your desired strings/words, which will be used as your menu's choices/options, which we'll then try to deal with, if we can get past this stuff / get the stringlist attribute created, example added string values: male, female, hermaphrodite, and asexual)


in the GUI/Editor (for the desktop/offline version, as I'm not sure if its the same for the online version):

'WHATEVER' scripting Element (Verb, Command, Turnscript, Timer, etc) -> add new script -> 'scripts' section/category -> 'call a function' Script -> (see below)

Function Name: show menu

and then set the rest of it up (hopefully it has the controls/options/boxes/etc for filling in the below):

prompt: Sex?
options: sex_object.sex_stringlist_attribute
cancelable: false
scripting: (see below, the: -> add new script -> 'scripts' .... etc etc etc)

// in code, it looks like this (you can see how it matches up with the GUI/Editor's controls/boxes/options above): show menu ("Sex?", sex_object.sex_stringlist_attribute, false) { /* scripting */ }

-> add new script -> 'scripts' section/category -> 'if' or 'switch' Scripts -> (see below)

if [EXPRESSION] result = "male"
-> then -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable player.sex_string_attribute = [EXPRESSION] "male"

else if [EXPRESSION] result = "female"
-> then -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable player.sex_string_attribute = [EXPRESSION] "female"

else if [EXPRESSION] result = "hermaphrodite"
-> then -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable player.sex_string_attribute = [EXPRESSION] "hermaphrodite"

else if [EXPRESSION] result = "asexual"
-> then -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable player.sex_string_attribute = [EXPRESSION] "asexual"

// or, using 'switch' Script/Function:

-> add new script -> 'scripts' section/category -> 'switch' or 'switch' Scripts -> (see below)

switch (result)

-> case ("male")
->-> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable player.sex_string_attribute = [EXPRESSION] "male"

-> case ("female")
->-> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable player.sex_string_attribute = [EXPRESSION] "female"

-> case ("hermaphrodite")
->-> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable player.sex_string_attribute = [EXPRESSION] "hermaphrodite"

-> case ("asexual")
->-> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable player.sex_string_attribute = [EXPRESSION] "asexual"


I said I want show menu then if. What are attributes?


How whould I do the first thing without code view?
Sorry for somehow posting that 2x, it seems I want menu then if for each of the options.... but when I go to if, I dont see an option that refers to the menu.

If you're using the GUI editor, with the "if" script there's a drop down which gives a lot of different types of conditions. The one you want is the first one, "expression".

When using the ask function, the expression for the if statement is just result - the result of the ask.

When using show menu, your expression would be something like result = "Yes".

Does that make sense? I'm not really sure how to describe these things.


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

Support

Forums