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

This actually won’t do what you expect. The parentheses are binary tests, and true/false converts to 1/2, so you will only have the blanks or “a match,” “a cigar,” or “a healing potion” displayed, never “two” or “some”.

Maybe try:

*if (item_hp >= 1) @{(item_hp = 1) a healing potion,|${item_hp} healing potions,}

Anyway, I’m really happy to see the @{} feature added. Enums, plus compact text substitution, all in the same concise syntax, is great.

@dfabulich I think the @{} syntax merits description on the Advanced Choicescript page.

4 Likes

Well, you’ve improved my theory, then!

[Achievement acquired]

Besides, I don’t think creating @{} for inventory where the number count of that certain item can go beyond 999 is plausible :sweat_smile:

@dfabulich Just out of curiosity, is nestable multireplace a potential future addition or just a flat-out impossibility? Multireplace alone is already spectacular, but I’ve oh so longed to nest them on several occasions.

Do you mean by nested multireplace is something like this?

*if nest
  @{hablah true|false}

If that’s the case, I believe it’s already doable.

1 Like

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.

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

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

1 Like

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.

6 Likes

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.

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! :sweat_smile:

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?

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.

2 Likes

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

Sorry, 60, yes. I missed that part. :stuck_out_tongue_winking_eye:

1 Like

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

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

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

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.

4 Likes

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:

*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

2 Likes

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

2 Likes

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

3 Likes

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.

9 Likes