How to print choices or object in a message

StrangeCloud9
29 Jan 2019, 17:01

For example, when the player opens a secret entrance, I want to print an object "secret entry" in a message, so that the player knows that there is a new thing and easily click that item in the message.
And sometimes I want to let players make a decision, how to print a choice problem in the message so that player could click to make choice?
For example, after players do something, there will be a message like:

  1. do it
  2. not do it
    and the player can click 1 or 2 to make a decision.
    Thanks!

Io
29 Jan 2019, 17:08
And sometimes I want to let players make a decision, how to print a choice problem in the message so that player could click to make choice?

Don't know about the first - hyperlinks maybe? - but for this you want to use the Menu block of code.


StrangeCloud9
29 Jan 2019, 19:59

I've updated my question. There is an example.


Io
29 Jan 2019, 20:36

You misunderstood. The example you provided is EXACTLY what Menu does. What I don't know is:

 I want to print an object "secret entry" in a message, so that the player knows that there is a new thing and easily click that item in the message.

and it's what I suggested hyperlinks for, but I've never done anything like that.

You had a two part question. I didn't know how to do part 1. I did know how to do part 2.


mrangel
29 Jan 2019, 22:44

For example, when the player opens a secret entrance, I want to print an object "secret entry" in a message, so that the player knows that there is a new thing and easily click that item in the message.

You can use the text processor:
msg ("You have found a {object:secret entry} in the corner of the room!")

or core functions:
msg ("You have found " + GetDisplayName(secret entry) + " in the corner of the room!")

(GetDisplayName will make the link and also add "a" or "an" as appropriate for the object name)

And sometimes I want to let players make a decision

Ask ("Do you want to do it?") {
  if (result) {
    // code to run if they choose "Yes" goes here
  }
  else {
    // code to run if they choose "No" goes here
  }
  // code to run after the results of the player's choice whether they choose yes or no should go here
}
// code here will be run after the question is DISPLAYED, but before an answer is chosen
// a common mistake is to put code here that depends on the answer even though the player hasn't chosen it yet

You could also do:

ShowMenu ("Do you want to do it?", Split("do it;don't do it"), false) {
  split (result) {
    case ("do it") {
      // code to run if they choose "do it" goes here
    }
    case ("don't do it") {
      // code to run if they choose "don't do it" goes here
    }
    default {
      // this code will only run if you mistyped one of the options
      // it's a good idea to show a message, so it's easier to fix if you made a mistake
      error ("Unexpected menu response: "+result)
    }
  }
  // code to run after the results of the player's choice whether they choose yes or no should go here
}
// code here will be run after the question is DISPLAYED, but before an answer is chosen
// a common mistake is to put code here that depends on the answer even though the player hasn't chosen it yet

StrangeCloud9
30 Jan 2019, 13:44

Thank you! exactly what I want!!