Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0

Adding new values to arrays, how?


Is it possible to add values to arrays through a script? Like how you use name ArrayName.add(value) on java, or ArrayName.append[] on Python?

Share this post

Link to post

2 answers to this question

Recommended Posts

  • 0

Value assignment is done by "arrayName[x] = y;", where "x" must be a non-negative number strictly lesser than the array's size. Size of an array is fixed to the value you declare the array with, and can't be changed at runtime.

Share this post

Link to post
  • 0

As long as you declare your array a certain size, those values are initialized at start. You can add values in-game with a script as usual, up to the declared size. But you cannot resize your array.


Be careful: if you have more than one script updating/reading the same array, you will run the real risk of experiencing race conditions. You cannot control which script will run first within a given tic.  If the values in your array are meant to convey information about a Thing, you're much better off storing those values in that Thing's COUNTx properties instead.

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now