Skip to content

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

NamespaceDescription
ambientBackground audio layer control
BigNumberArithmetic on integers larger than 32 bits
colorColor creation, conversion, and interpolation
drawLow-level screen drawing
eventCommunity / seasonal event objectives
intInteger parsing
itemItem queries (cooldowns, counts, loadouts)
keyInput rebinding
locLocation control (leave, pause)
mathFull mathematics library
musicMusic playback
playerPlayer cosmetic effects
screenCoordinate conversion and camera movement
storagePersistent key-value storage
stringString manipulation
sysSystem / import configuration
teText localisation
timeTime formatting
uiUser 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 R

Type 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.

Stonescript is part of Stone Story RPG.