Page 1 of 1

If SetArray is called,will its value remained active to the next turn

Posted: Fri Mar 03, 2023 6:09 am
by locustmustdie

Code: Select all

SetArray(me,value,index);
Will the value of the array remained to the next turn? Is there clearArray() function to handle this?

Re: If SetArray is called,will its value remained active to the next turn

Posted: Fri Mar 03, 2023 7:51 am
by rbodleyscott
locustmustdie wrote: Fri Mar 03, 2023 6:09 am

Code: Select all

SetArray(me,value,index);
Will the value of the array remained to the next turn?
There is really only one 256 x 8 system array, and it is likely to be re-used by the vanilla scripts in the interim. So don't try using it. It is rather a fossil leftover from the old STUB engine, anyway. ARCHON supports proper user defined global variables and arrays. The old system Array is only used in the current scripts because it wasn't worth changing them in code carried forward from Pike and Shot when we switched engines.

The cool ARCHON kids are now using proper global arrays for anything that needs to persist outside the function it is in. You can see how these are created in Globals.bsf and LiaisonTools.bsf.

I cannot think of any reason why they cannot be defined in a scenario script.

Make sure you don't use any of the existing global variable names. As far as I recall, they are all in those two files.
Is there clearArray() function to handle this?
ClearArray(value, [array]);

-------------------------

Note that while Attribs and AttribArrays are automatically set to 0 at the start of each battle, global variables and arrays are not, so if you need old data to be cleared from them at the start of each battle, you will need to script that yourself.

Re: If SetArray is called,will its value remained active to the next turn

Posted: Fri Mar 03, 2023 9:17 am
by locustmustdie
Thanks,Richard! I believe with the help of array,some skyrocket length segments can be avoided.

Re: If SetArray is called,will its value remained active to the next turn

Posted: Fri Mar 03, 2023 10:28 am
by rbodleyscott
locustmustdie wrote: Fri Mar 03, 2023 9:17 am Thanks,Richard! I believe with the help of array,some skyrocket length segments can be avoided.
I won't pretend to understand that.

As I say, DO NOT USE THE SYSTEM ARRAY! (Can't be clearer than that)

Re: If SetArray is called,will its value remained active to the next turn

Posted: Fri Mar 03, 2023 10:45 am
by locustmustdie
rbodleyscott wrote: Fri Mar 03, 2023 10:28 am
locustmustdie wrote: Fri Mar 03, 2023 9:17 am Thanks,Richard! I believe with the help of array,some skyrocket length segments can be avoided.
I won't pretend to understand that.

As I say, DO NOT USE THE SYSTEM ARRAY! (Can't be clearer than that)
got it