Native Functions
While scripts can define their own functions, Stonescript ships with a set of pre-defined native functions that behave similarly to commands but are more clearly grouped by subject, can accept parameters, and often return a value.
Namespaces
| Namespace | Description |
|---|---|
| ambient | Background audio layer control |
| BigNumber | Arithmetic on integers larger than 32 bits |
| color | Color creation, conversion, and interpolation |
| draw | Low-level screen drawing |
| event | Community / seasonal event objectives |
| int | Integer parsing |
| item | Item queries (cooldowns, counts, loadouts) |
| key | Input rebinding |
| loc | Location control (leave, pause) |
| math | Full mathematics library |
| music | Music playback |
| player | Player cosmetic effects |
| screen | Coordinate conversion and camera movement |
| storage | Persistent key-value storage |
| string | String manipulation |
| sys | System / import configuration |
| te | Text localisation |
| time | Time formatting |
| ui | User interface construction |
Calling convention
Native functions are called exactly like script-defined functions:
stonescript
var result = math.Sqrt(9)
>result = @result@Some functions have no return value (they act as commands):
stonescript
ambient.Stop()
music.Play(temple_0)Others return a value that can be stored or used inline:
stonescript
?item.CanActivate()
activate RType function
There is also a built-in Type() function outside any namespace:
stonescript
var a = 0
?Type(a) = int
>Variable 'a' is an integer.Possible return values: string, int, bool, function, object, null.