In-line "if-then" statement delivers text


#1

Hi! I’d like to use an if-then statement in-line to deliver a text variable. For example:

You pull out a *if friend = “John” then “gun” else “feather” and point it at him.

If your friend is John, it says:
You pull out a gun and point it at him.

If your friend is not John, it says,
You pull out a feather and point it at him.

Is this possible, or do I have to create a whole variable for one-off word replacements like this?

What’s the most efficient way to do this, please?

Thanks very much!!
Angel…


#2

First, you only need the variable friend. You can default this to John.

*create friend “John”

Later this can be changed.

What is your friends name?
*choice
  #John
    Your friend is called ${friend}.
    *goto friend_name_set
  #Bob
    *set friend "Bob"
    Your friend is called ${friend}.
    *goto friend_name_set
  #Pete
    *set friend "Pete"
    Your friend is called ${friend}.
    *label friend_name_set

Now, onto the part you want. I would code it like this:

You pull out a
*if friend = "John"
  gun
  *goto point
feather
*label point
and point it at him.

#3

I see what you did there! Smooth! Thanks very much for the assist! I’ve tested it in my game and it works beautifully.


#4

Do you usually pull guns on your friends and feathers on your enemies? =P


#5

That does sound a bit backwards, doesn’t it? LOL.