Skip to main content

Script

The Script plugin is an implementation of the SceneScript interface that enables run-time C++ compilation and dynamic loading. It compiles C++ source code using the platform native compiler into a dynamic library and then loads symbols directly from that library. This supports dynamic scripting workflows on Windows (Visual Studio), Linux (Clang and GCC), and macOS (Clang) during development.

For release builds, the plugin searches for script symbols within the application binary itself, enabling cross-platform deployment without requiring a compiler or dynamic library support at runtime. Tellusim Explorer can export all project scripts into a single source file, which should be included in the release build to embed all scripts.

The Script plugin provides run-time for GraphScript, NodeScript, and MaterialScript objects.

info

The SceneScript interface can be implemented for other languages such as C#, Rust, or Swift to enable them as scripts.

info

This plugin is integrated into both Tellusim Explorer and Tellusim Executor.

#include <system/script/include/TellusimScript.h>

Example

Script script;

// Script source
const char *src =
"#include <core/TellusimLog.h>\n"
"extern \"C\" SCRIPT_API void script() {\n"
" TS_LOG(Message, \"Hello World!\\n\");\n"
"}\n";

// Create script
if(!script.createScript("script", src)) return false;

// Run script function
using Callback = void();
Callback *func = (Callback*)script.getFunction("script");
if(func == nullptr) return false;

func();