New in ChoiceScript: *create_array, *temp_array commands, *page_break_advertisement

So we don’t have to create random values and have formulations to activate event based on the result.
I used to create temp and than random die values so when dice rolled it will act on the result like tabletop board games logic.

The arrays are like in js arrays
So bracket numbers act as index.numbers.
Also can we have array.length logic to optimize even further?

Edit: I am asking for array.length because authors can use it like thia,

Create_array footsoldier1

Create_array footsoldier 5

Consider logic;
If create_array.length > 5
Goto label overrun
Goto label counter

Just a method I thougt while reading. I believe many usage logic will be found as well.


Nice. I’ll try this for my big RD content patch.

I don’t suppose *create_array supports creating two-dimensional arrays? That syntax looks like it excludes that possibility.

Also, how are *delete and *delete_array supposed to be used?

Awesome! When will this version of Choice Script be included with CSIDE? Also, are these featured usable in production now or should wip games refrain from using them at the time?

Congrats @CJW! That was an amazing contribution :partying_face:


yooooooooooo this is excellent

@CJW you definitely deserve “a raise” for this (heh)


Oops, I forgot to mention, *create_array does create a count variable also. I updated my post.


In my experience, they’re rarely used, and really only useful for *temp variables.

1 Like

Truly ecstatic to finally see this land. I hope it can help simplify many a startup.txt file! :wink:
Thank you for being open to (and tidying up) this contribution @dfabulich!

Sadly not. You can use create/temp_array to extend an existing array into two dimensions:

*create_array player 5 ""
*create_array player_1_attribute 2 "strength" "wisdom"
*create_array player_2_attribute 2 "strength" "wisdom"
*create_array player_3_attribute 2 "strength" "wisdom"
*create_array player_4_attribute 2 "strength" "wisdom"
*create_array player_5_attribute 2 "strength" "wisdom"

But unfortunately there is still some repetition (much less than before though!).

*delete my_variable
*delete_array my_array

Trying to refer to those same variables after such a command is used will cause a ‘non existent array/variable’ error. As Dan mentions above, there probably isn’t very often a practical use for them.

Awesome! When will this version of Choice Script be included with CSIDE? Also, are these featured usable in production now or should wip games refrain from using them at the time?

Maybe this weekend…? ASAP, certainly!


We’ll also have to wait a bit for @dashingdon to be updated to support these commands.


This is an incredible QoL improvement — can’t wait to yeet 200+ *create lines from my startup file.

Does the length parameter accept any expression that evaluates to a positive integer? Would

*create_array pc_skills (num_skills[{pc_class}] + num_bonus_skills) ""

be valid?

1 Like

No. *create commands can only use strings and numbers, because if the player starts playing your game, pauses for a while, and then upgrades to a newer version with a new stat, the newer version must provide a static value for the stat.

So *create constitution 50 is fine, because if we have to create constitution in the middle of the game, we know what to set it to: 50. *create constitution ((strength + dexterity) / 2) isn’t allowed, because it’s not clear whether we’re supposed to use the player’s current strength and dexterity values, or the original values, or the new starting values (if they’re different).

I think it might make sense to allow *temp_array to have a dynamic length, but it doesn’t do that right now.


Awesome. Thanks @CJW. You just made life easier for everyone.

1 Like

I hope to have time this weekend to update the code base to the latest version and re-implement the dashingdon API.


@CJW you’re great. :clap:

By the way, do these commands work in the online, browser based choicescript ide ?

1 Like

They will after the weekend :relaxed:


This is awesome! Thanks @both of you, this is really useful.

Is it recommended to use *delete/*delete_array? Are there known performance issues with creating arrays and not deleting them?

1 Like

6 posts were split to a new topic: Deprecate *fake_choice?

As promised, CSIDE now supports these commands: [CSIDE] The ChoiceScript IDE (v1.3.3 Now Available — 05/09/2022) - #1189 by CJW


If anyone is curious how much simpler these commands can make your code, check out this CSLIB patch: Simplify code with array creation commands by CareyJWilliams · Pull Request #48 · ChoicescriptIDE/cslib · GitHub

That’s a nett reduction of 164 lines of code, without losing any functionality! :smiley:
I personally think the readability improves a lot as well, in most cases at least.

The only thing I thought when writing that is that perhaps I should have included a *set_array as well …, oh well, next time, maybe :wink:


Thanks for fixing the trigonometric functions too!