Jump to content
  • 0

Adding new values to arrays, how?


Nexxtic

Question

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...