Modules (IMPORT://)

IMPORT://mathutils      // loads mathutils.ton (a user module — see the guide below)
IMPORT://ton.mathutils  // loads the *built-in* ton.mathutils module — note the "ton." prefix

The leading ton. is how the parser tells a built-in module apart from a user module — it's never a filesystem lookup. See Built-in system modules for the full list of built-ins, and the guide below for writing your own.

Namespaces (since beta-2.0.0) — IMPORT://name as alias loads a module without adding its names to the global scope: they're reached through the alias instead. For a built-in module the module_ prefix is dropped.

IMPORT://mathutils as m
print(m.add(2, 3))

IMPORT://ton.strings as s
print(s.snake_case("helloWorld"))     // strings_snake_case -> s.snake_case

Subfolders — IMPORT://utils/text loads utils/text.ton (next to the script, or in modules/).

Edit this page on GitHub