Imortant: you must initialize arrays to something, even if it’s an empty array.
var floatArray as float []; won’t give syntax errors, but upon reloading your game, you will get an error and your script won’t work.
Instead, initialize empty arrays like this var floatArray as float [] = [];
If you now think “wait, haven’t I seen these brackets before?”, you have.
Remember recipes.add(out,[[],[],[]]);?
This uses three arrays with each containing up to three entries to define a crafting table recipe.
You surely have noticed that all arrays here have the as statement appended.
Why you ask?
This is because ZenScript sometimes cannot predict what type the items in the array are. This can be the cause of strange conversion error logs!
Better be safe than sorry and cast the Arrays to their correct types!
Also, if you cast to non-primitive types (everything except strings, ints and the same) be sure to import the corresponding package and be sure to do so at the TOP of the script:
The main use of the for-loop is iterating through an array. Iterating means doing an action to all elements of an array.
You can use the break keyword to break the loop prematurely.
While it is not recommended to do so, it is possible to add some Objects to Arrays.
You can only add single Objects to an array, you cannot add two arrays.
You use the + operator for array Addition: