# New features in ChoiceScript: change text size/color, hyphen spacing, @{} variable replacement

**URL:** <https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217>\
**Category:** Announcements\
**Tags:** choicescript-updates\
**Created:** [May 1, 2017, 4:01am UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217 "2017-05-01T04:01:17Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Nonvita](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/nonvita/32/29708_2.png) [@Nonvita](https://forum.choiceofgames.com/u/Nonvita)\
**Post date:** [June 24, 2017, 4:00pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/42 "2017-06-24T16:00:49Z")

</div>

Yeah, a combination of \*if statements with multireplace is possible, but I’d be looking for something more like  
@{damage+1 You miss.|You do 1 damage with your @{weapon sword|dagger|mace|carrot}.}

Totally fake example, but yes I’m dealing with a lot of ifs that could be much more elegant with nested (or nested in nested—a girl can dream, right?) mutireplace.

---

<div class="post-metadata">

**Author:** ![Szaal](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/szaal/32/112202_2.png) [@Szaal](https://forum.choiceofgames.com/u/Szaal)\
**Post date:** [June 24, 2017, 4:06pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/43 "2017-06-24T16:06:34Z")

</div>

Humm… I can see where’s your question comes from.

* * *

When you think about it, I think your code can be like this  
`@{damage+1 You miss.|You do 1 damage with your ${weapon sword|dagger|mace|carrot}.}`

considering @{@{}} is not a possible combination. Not yet, at least.

But I admit, coding `*set weapon 123` is much faster and more practical than `*set weapon "carrot"`.

---

<div class="post-metadata">

**Author:** ![CJW](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cjw/32/111787_2.png) [@CJW](https://forum.choiceofgames.com/u/CJW)\
**Post date:** [June 24, 2017, 4:38pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/44 "2017-06-24T16:38:51Z")

</div>

Whilst I agree this would be cool, I get the impression it might be abused and lead to some really hard to read code?

---

<div class="post-metadata">

**Author:** ![Minnow](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Minnow](https://forum.choiceofgames.com/u/Minnow)\
**Post date:** [June 24, 2017, 7:38pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/45 "2017-06-24T19:38:27Z")

</div>

You may not be able to do it directly with a single line of code, but you can do it indirectly.

```
*temp temp1 "@{weapon sword|dagger|mace|carrot}"
@{damage+1 You miss.|You do 1 damage with your ${temp1}.}

```

I tested, and it seems to work exactly as expected! It’s not quite nested, but it may simplify a mess of `*if` commands anyway.

---

<div class="post-metadata">

**Author:** ![Nonvita](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/nonvita/32/29708_2.png) [@Nonvita](https://forum.choiceofgames.com/u/Nonvita)\
**Post date:** [June 25, 2017, 2:29am UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/46 "2017-06-25T02:29:34Z")

</div>

Nice idea, I’ll have to check if that would help with any of my code. I’ve mostly ended up either combining with \*if statements or separating the multireplaces across multiple variables.

> [@CJW](#):
>
> Whilst I agree this would be cool, I get the impression it might be abused and lead to some really hard to read code?

Haha, perhaps too much nesting would get a little out of hand. Seeing how much more compact my code is thanks to multireplace, though, I’d imagine that 1 nested level could actually still make the code clearer. But I could be wrong!

Sure, it’s not at all a necessary feature, but then neither are many of the more programming-heavy features, yet they can be really helpful to people who do choose to utilize them. Anyway, it’s just me dreaming! 😅

---

<div class="post-metadata">

**Author:** ![Fiogan](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/fiogan/32/215832_2.png) [@Fiogan](https://forum.choiceofgames.com/u/Fiogan)\
**Post date:** [November 22, 2017, 8:09pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/47 "2017-11-22T20:09:30Z")

</div>

Question about multireplace:

If I have numerous places where I want to check if a particular variable is over a certain quantity, is code like this acceptable?

`@{(languages + 59) the foreign tongue | Deeplandish}`

It’s tidier than

```
*if (languages > 60)
  Deeplandish
*if (languages <= 60)
  the foreign tongue

```

I hesitate to just use a variable because the checks aren’t all quite the same, and besides, this way I can tweak the text to its surrounding prose.

Is there any reason why this would be a bad idea?

---

<div class="post-metadata">

**Author:** ![ParrotWatcher](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/parrotwatcher/32/49963_2.png) [@ParrotWatcher](https://forum.choiceofgames.com/u/ParrotWatcher)\
**Post date:** [November 22, 2017, 8:25pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/48 "2017-11-22T20:25:47Z")

</div>

> [@Fiogan](#):
>
> @{(languages + 59) the foreign tongue | Deeplandish}

It would be `@{(languages <= 59) the foreign tongue | Deeplandish}` in this case. You want the first part to be something an `*if` will see as either `true` or `false`, whereas `language + 59` is just a number.

---

<div class="post-metadata">

**Author:** ![Fiogan](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/fiogan/32/215832_2.png) [@Fiogan](https://forum.choiceofgames.com/u/Fiogan)\
**Post date:** [November 22, 2017, 8:26pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/49 "2017-11-22T20:26:53Z")

</div>

@ParrotWatcher But the numbers are 60 and 61, right…and oh, I see. Wooops. XD Thanks so much! I’ll sort that.

---

<div class="post-metadata">

**Author:** ![ParrotWatcher](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/parrotwatcher/32/49963_2.png) [@ParrotWatcher](https://forum.choiceofgames.com/u/ParrotWatcher)\
**Post date:** [November 22, 2017, 8:27pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/50 "2017-11-22T20:27:42Z")

</div>

Sorry, 60, yes. I missed that part. 😜

---

<div class="post-metadata">

**Author:** ![Fiogan](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/fiogan/32/215832_2.png) [@Fiogan](https://forum.choiceofgames.com/u/Fiogan)\
**Post date:** [November 22, 2017, 8:28pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/51 "2017-11-22T20:28:22Z")

</div>

And I missed basically everything logical. `;p` This makes this whole passage work so much better, though, yay! Thanks again, very much obliged.

---

<div class="post-metadata">

**Author:** ![Szaal](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/szaal/32/112202_2.png) [@Szaal](https://forum.choiceofgames.com/u/Szaal)\
**Post date:** [November 22, 2017, 8:29pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/52 "2017-11-22T20:29:50Z")

</div>

Just a quick-guide to help anyone understand how the syntax works.

```
*set lamp 1
@{(lamp = 1) on|off}

```

---

<div class="post-metadata">

**Author:** ![Fiogan](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/fiogan/32/215832_2.png) [@Fiogan](https://forum.choiceofgames.com/u/Fiogan)\
**Post date:** [November 22, 2017, 8:33pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/53 "2017-11-22T20:33:42Z")

</div>

Right, thank you.

I’d been using multireplace properly for variables where, for instance, biting\_daisies = 1 (or 2, 3, 4, etc.) but then it occurred to me that multireplace would be really useful for some of my on/off `*if` flavour text. But I nearly implemented it all wrong, because my way would have only worked if the player had exactly 60 or 61 in languages. I hadn’t thought it through properly; too excited about ending the endless string of `*if` statements, I suppose.

---

<div class="post-metadata">

**Author:** ![Minnow](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Minnow](https://forum.choiceofgames.com/u/Minnow)\
**Post date:** [November 22, 2017, 8:37pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/54 "2017-11-22T20:37:50Z")

</div>

> [@Fiogan](#):
>
> because my way would have only worked if the player had exactly 60 or 61 in languages.

Actually, it would’ve thrown an error. I drew up a little test file while I was composing my reply (which then got ninja’d to the point I didn’t need to post anymore.) My code looked like this:

```choicescript
*create languages 50
You hear people conversing in @{(languages + 59) the foreign tongue|Deeplandish}.

```

It gave me the following error:  
line 7 of startup: invalid @{} at letter 31; ‘languages + 59’ is equal to 109 but there are only 2 options

---

<div class="post-metadata">

**Author:** ![Eiwynn](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/eiwynn/32/221334_2.png) [@Eiwynn](https://forum.choiceofgames.com/u/Eiwynn)\
**Post date:** [November 22, 2017, 8:40pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/55 "2017-11-22T20:40:35Z")

</div>

> [@Fiogan](#):
>
> biting\_daisies = 1 (or 2, 3, 4, etc.)

Perhaps the following is correct: A girl and her flowers. @{(girl = 1) daisies|sunflowers}

---

<div class="post-metadata">

**Author:** ![Fiogan](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/fiogan/32/215832_2.png) [@Fiogan](https://forum.choiceofgames.com/u/Fiogan)\
**Post date:** [November 22, 2017, 8:44pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/56 "2017-11-22T20:44:09Z")

</div>

So here 1 means she has daisies and 2 means she has sunflowers, right? If you wanted to replace flowers, you’d use:

`A girl and her @{girl daisies|sunflowers}.`

At least, if I’m understanding correctly. Then if you wanted her to have other flowers for values of 3 and 4 and what have you, as long as one keeps track of what number equates to what state, it’s possible to just expand into

`A girl and her @{girl daisies|sunflowers|nasturtiums|Venus flytraps}.`

---

<div class="post-metadata">

**Author:** ![Minnow](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Minnow](https://forum.choiceofgames.com/u/Minnow)\
**Post date:** [November 22, 2017, 9:28pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/57 "2017-11-22T21:28:59Z")

</div>

I’ve mentioned this elsewhere, but if you set a character’s `gender` variable as numeric instead of a string, you can simplify plural-variant verbs for “they/them” pronouns. For example:

```
*fake_choice
	#Non-binary.
		*set gender 1
		*set they "they"
	#Female.
		*set gender 2
		*set they "she"
	#Male.
		*set gender 3
		*set they "he"

```

Then you can insert things like `@{gender teach|teaches|teaches}` or `@{gender go|goes|goes}` inline instead of breaking your sentences apart to use structures things like:

```
*if gender = "non-binary"
	teach
*if gender != "non-binary"
	teaches

*if gender = "non-binary"
	go
*if gender != "non-binary"
	goes

```

And you can use that in conjunction with (or instead of) pronoun variables:

```
$!{they} @{gender go|goes|goes} to the market every Saturday morning.
@{gender They go|She goes|He goes} to the market every Saturday morning.

```

Edit: You can leave an option within the multireplace blank as well. So you could also do:

`$!{they} go@{gender |es|es} to the market every Saturday morning.`

---

<div class="post-metadata">

**Author:** ![DeepPars](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@DeepPars](https://forum.choiceofgames.com/u/DeepPars)\
**Post date:** [November 23, 2017, 2:22am UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/58 "2017-11-23T02:22:30Z")

</div>

Great implementations!  
As for a name, why not go with what it really is - switch case?

Also, please reflect all of these updates at [your page](https://www.choiceofgames.com/make-your-own-games/choicescript-intro/). Would make sense if budding authors would be cognizant of all what ChoiceScript has to offer.

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [January 21, 2018, 9:24am UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/59 "2018-01-21T09:24:24Z")

</div>

I’ve just added a variation of @Minnow’s suggestion over on the [Wiki](http://choicescriptdev.wikia.com/wiki/Multireplace).

The only difference is that instead of a numeric gender variable (they = 1, she = 2, he = 3), I’m suggesting a Boolean, “plural,” to keep things simpler. In English, I don’t think there are any verbs that conjugate differently for he and she. So it could work like this:

```
My preferred pronoun is
*fake_choice
	#They.
		*set plural true
		*set they "they"
	#Royal We.
		*set plural true
		*set they "we"
	#She.
		*set they "she"
	#He.
		*set they "he"

```

and then inside the multireplace brackets, we only need: `@{plural go|goes}` without the need for a third option.

Feel free to suggest edits to the Wiki. I’m still new to multireplace, and to coding for nonbinary characters. 🙂

---

<div class="post-metadata">

**Author:** ![Eiwynn](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/eiwynn/32/221334_2.png) [@Eiwynn](https://forum.choiceofgames.com/u/Eiwynn)\
**Post date:** [January 21, 2018, 1:19pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/60 "2018-01-21T13:19:51Z")

</div>

> [@Havenstone](#):
>
> Feel free to suggest edits to the Wiki. I’m still new to multireplace, and to coding for nonbinary characters.

Would you also include Minnow’s because I’ve started using numeric variables for the majority of my coding?

The reason I am using numeric variables as much as possible is to reinforce consistency.

---

<div class="post-metadata">

**Author:** ![GoldenSilver](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/goldensilver/32/110153_2.png) [@GoldenSilver](https://forum.choiceofgames.com/u/GoldenSilver)\
**Post date:** [January 21, 2018, 2:34pm UTC](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217/61 "2018-01-21T14:34:52Z")

</div>

> [@Havenstone](#):
>
> I’ve just added a variation of @Minnow’s suggestion over on the Wiki.

Nice, when I created the page I just added some basic explanation but no examples like these; that’s cool.

I noticed there are no pages for \*params and for arrays. I can do those later and explain how to use them.

[Previous page](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217.md?page=2)

[Next page](https://forum.choiceofgames.com/t/new-features-in-choicescript-change-text-size-color-hyphen-spacing-variable-replacement/26217.md?page=4)
