Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

export_namespace

Exports a callback of the calling script as a function in a script namespace, so that any script (in any language) can call it.

The callback is either a function registered with register_callback, or a top level function with that name. Calls run in the exporting script and return what the callback returns.

register_callback("spawn_enemy_impl", function(health) ... end)
export_namespace("script.game", "spawn_enemy", "spawn_enemy_impl")
-- in another script, once the first one has run
import_namespace("script.game").spawn_enemy(5)

Arguments

NameTypeDocumentation
nameStringthe name of the function within the namespace.
callbackStringthe label of the callback of this script to export.
arg3StringNo Documentation 🚧

Returns

NameTypeDocumentation
result()Nothing if the function was exported.