CSL gives you a few “array-like” tools that cover most gameplay needs: fixed arrays, slices, and dynamic arrays. This page is the practical guide to using them without foot-guns.
Quick glossary
Fixed array: [N]T — size is known at compile time.
Slice / managed array: []T — a view over array data (often used for parameters).
Dynamic array: [..]T — resizable list with count and capacity.
If you know you’ll add a lot of items, reserve first to avoid repeated reallocations.
Removing items
You generally pick between fast removal (order doesn’t matter) and ordered removal (preserve order).
You can also remove by index:
Clearing
Passing arrays into procedures
Many APIs accept []T (a slice/view). Dynamic arrays can be passed where []T is expected.
Iteration patterns
Iterate elements
Iterate indices (inclusive ranges)
0..n-1 is common for “slot-style” loops:
Ranges are inclusive. If you want a typical “0 to count-1” loop, write 0..count-1.
Closures, callbacks, and userdata (important)
CSL does not have closures. Inline proc() { ... } definitions cannot capture surrounding variables.
When you need callbacks (UI handlers, death hooks, etc), pair the callback with a userdata: Object field.
API reference
Each project includes an api_reference/ folder containing the latest core API surface. If you’re trying to find “what methods exist on this type?”, that folder is the source of truth.
values: [..]int;
values->append(10);
values->append(20);
values->append(30);
values->unordered_remove_by_value(20); // swaps with last, fast
values->ordered_remove_by_value(10); // shifts, keeps order