Updated documents (mainly array functions)

This commit is contained in:
NovaRain
2023-10-16 11:34:45 +08:00
parent c7ecf1c070
commit f46ffb4ea5
4 changed files with 21 additions and 21 deletions
+13 -13
View File
@@ -193,7 +193,7 @@ _*mixed means any type_
#### `void resize_array(int arrayID, int size)`
- changes array size
- applicable to maps too, but only to reduce elements
- there are number of special negative values of "size" which perform various operations on the array, use macros `sort_array`, `sort_array_reverse`, `reverse_array`, `shuffle_array` from **sfall.h** header
- there are number of special negative values of "size" which perform various operations on the array, see macros `sort_array`, `sort_array_reverse`, `reverse_array`, `shuffle_array`, `sort_map_value`, and `sort_map_reverse` from **sfall.h** header
#### `void free_array(int arrayID)`
- deletes any array
@@ -206,18 +206,7 @@ _*mixed means any type_
#### `int len_array(int arrayID)`
- returns number of elements or key=>value pairs in a given array
- if array is not found, returns -1 (can be used to check if given array exist)
#### `mixed array_key(int arrayID, int index)`
- don't use it directly; it is generated by the compiler in foreach loops
- for lists, returns index back (no change)
- for maps, returns a key at the specified numeric index (don't rely on the order in which keys are stored though)
- can be checked if given array is associative or not, by using index (-1): 0 - array is list, 1 - array is map
#### `int arrayexpr(mixed key, mixed value)`
- don't use it directly; it is used by compiler to create array expressions
- assigns value to a given key in an array, created by last `create_array` or `temp_array` call
- always returns 0
- if array is not found, returns -1 (can be used to check if given array exist)
#### `void save_array(mixed key, int arrayID)`
- makes the array saveable; it will be saved in **sfallgv.sav** file when saving the game
@@ -230,6 +219,17 @@ _*mixed means any type_
- loads array from savegame data by the same key provided in `save_array`
- returns array ID or zero (0) if none found
#### `mixed array_key(int arrayID, int index)`
- don't use it directly; it is generated by the compiler in foreach loops
- for lists, returns index back (no change)
- for maps, returns a key at the specified numeric index (don't rely on the order in which keys are stored though)
- can be checked if given array is associative or not, by using index (-1): 0 - array is list, 1 - array is map
#### `int arrayexpr(mixed key, mixed value)`
- don't use it directly; it is used by compiler to create array expressions
- assigns value to a given key in an array, created by last `create_array` or `temp_array` call
- always returns 0
___
### BACKWARD COMPATIBILITY NOTES