diff --git a/arrays/index.html b/arrays/index.html index 1b88bd14..92ffa7ab 100644 --- a/arrays/index.html +++ b/arrays/index.html @@ -64,4 +64,4 @@ // kaboom!!! end end -
*mixed means any type
int create_array(int size, int flags): size >= 0, creates list with given sizesize == -1, creates map (associative array)size == -1 and flags == 2, creates a “lookup” map (associative array) in which the values of existing keys are read-only and can’t be updated. This type of array allows you to store a zero (0) key value int temp_array(int size, int flags): create_array, only created array becomes “temporary”void fix_array(int arrayID): void set_array(int arrayID, mixed key, mixed value): arrayID[key] := value;mixed get_array(int arrayID, mixed key): (arrayID[key])void resize_array(int arrayID, int size): sort_array, sort_array_reverse, reverse_array, shuffle_array from sfall.h headervoid free_array(int arrayID): mixed scan_array(int arrayID, mixed value): int len_array(int arrayID): mixed array_key(int arrayID, int index): int arrayexpr(mixed key, mixed value): create_array or temp_array callvoid save_array(mixed key, int arrayID): int load_array(mixed key): save_arrayFor those who used arrays in their mods before sfall 3.4:
There is an INI parameter ArraysBehavior in Misc section of ddraw.ini. If set to 0, all scripts which used sfall arrays before should work. This basically changes that create_array will create permanent arrays which are “saved” by default and their IDs are also permanent. It is 1 by default.
NOTE: Starting from sfall 4.3.3/3.8.33, the ArraysBehavior option is removed, and arrays always work in ArraysBehavior=1 mode. Make sure to review your scripts if you need to save arrays into savegames.
How savegame compatibility is handled?
Saved arrays are stored in sfallgv.sav file (in savegame) in new (more flexible) format, just after the old arrays. So basically, when you load older savegame, sfall will load arrays from old format and save them to new format on next game save. If you load savegame made with sfall 3.4 using sfall 3.3 (for example), the game shouldn’t crash, but all arrays will be lost.
Previously you had to specify size in bytes for array elements. This parameter is now ignored and you can store strings of arbitrary length in arrays.