So about Arrays

I’m just double checking that when you make an array, the base name is the number value the array is set to.

Say for example:

*create_array hairc 9 “pure onyx” “burnt umber” “chestnut shells” “polished copper” “honey gold” “blushed flax” “frosted silver” “fresh snow” “ERROR”

can you say…

*set hairc 3

To set it to “chestnut shells”? Or does it not work like that?

I have taken a break from scipting so I feel like I don’t remember how to do anything :sob:

arrays in cs are basically shortcuts to indexing variables with the element index.

*create_array test 3 “a” “b” “c”

is the equivalent of

*create test_1 “a”
*create test_2 “b”
*create test_3 “c”

What you want to do is make another variable for player hair color and set it to a value of the array by its index.

*set playerHair hairc[3]


*set playerHair hairc_3


That’s what I remembered but I was just double checking since I couldn’t remember, so there essentially isn’t a variable just named hairc? So I could just

*create_array hairc 9 “…”

*create n_hairc 3
*create t_hairc (hairc[n_hairc])

Then set it whenever

*set hairc 5
*set t_hairc (hairc[n_hairc])

Don’t do this. Unless proved otherwise (I didn’t test), I’m pretty sure it doesn’t do what you want here.

*create_array hairc 9 “…”

Will create another variable called hairc_count with a value of 9, if that’s what you mean? Otherwise I’m really struggling to understand what you’re trying to do with the extra variables.

1 Like

The array is just… the array, n_hairc is the numerical value you set the hair to and t_hairc is what I want to show up

Like having to type out ${hairc[n_hairc]} is a bit of a mouthful to do every time you want to include a variable, so t_hairc is supposed to be a shorthand for that.

so t_hairc is supposed to be set to “chestnut shells” in the case where n_hairc is equal to 3

*create_array hairc 9...

Won’t create a variable “hairc”, so you’re welcome to use it. I wouldn’t recommend it though, try to be as expressive and unique with your variable names as possible. This is especially important in ChoiceScript as there’s no type safety, so it’s really easy to accidentally assign the wrong values to the wrong variables.

Otherwise I think what you’re going for is fine.

You don’t need brackets here: *create t_hairc (hairc[n_hairc])

1 Like

I just got in the habit of using brackets because my software constantly screams at me that it’s “wrong” if I don’t and I prefer not to see the red flags.