Updated documents (mainly array functions)

This commit is contained in:
NovaRain
2023-10-16 11:32:52 +08:00
parent e2b5a0652d
commit 143ec750cf
6 changed files with 103 additions and 70 deletions
+11 -11
View File
@@ -212,17 +212,6 @@ _*mixed means any type_
- 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
* `void save_array(mixed key, int arrayID)`:
- makes the array saveable; it will be saved in **sfallgv.sav** file when saving the game
- arrayID is associated with given "key"
@@ -234,6 +223,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
For those who used arrays in their mods before sfall 3.4: