# In-line "if-then" statement delivers text

**URL:** <https://forum.choiceofgames.com/t/in-line-if-then-statement-delivers-text/5156>\
**Category:** ChoiceScript Help\
**Created:** [September 7, 2014, 1:56am UTC](https://forum.choiceofgames.com/t/in-line-if-then-statement-delivers-text/5156 "2014-09-07T01:56:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Angel](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/angel/32/1881_2.png) [@Angel](https://forum.choiceofgames.com/u/Angel)\
**Post date:** [September 7, 2014, 1:56am UTC](https://forum.choiceofgames.com/t/in-line-if-then-statement-delivers-text/5156/1 "2014-09-07T01:56:45Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![andymwhy](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/andymwhy/32/34396_2.png) [@andymwhy](https://forum.choiceofgames.com/u/andymwhy)\
**Post date:** [September 7, 2014, 2:18am UTC](https://forum.choiceofgames.com/t/in-line-if-then-statement-delivers-text/5156/2 "2014-09-07T02:18:35Z")

</div>

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.
```

---

<div class="post-metadata">

**Author:** ![Angel](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/angel/32/1881_2.png) [@Angel](https://forum.choiceofgames.com/u/Angel)\
**Post date:** [September 7, 2014, 2:34am UTC](https://forum.choiceofgames.com/t/in-line-if-then-statement-delivers-text/5156/3 "2014-09-07T02:34:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MutonElite](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@MutonElite](https://forum.choiceofgames.com/u/MutonElite)\
**Post date:** [September 7, 2014, 11:08am UTC](https://forum.choiceofgames.com/t/in-line-if-then-statement-delivers-text/5156/4 "2014-09-07T11:08:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Angel](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/angel/32/1881_2.png) [@Angel](https://forum.choiceofgames.com/u/Angel)\
**Post date:** [September 7, 2014, 5:18pm UTC](https://forum.choiceofgames.com/t/in-line-if-then-statement-delivers-text/5156/5 "2014-09-07T17:18:13Z")

</div>

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