# Writing Scripts > 🚧 **Note:** For advanced scripting features (UI, 3D, live editing), see Roadmap.md for future plans! This guide explains how to write scripts for Graphite using C++ and the provided interfaces. --- ## Script Structure Scripts must implement the `ScriptInterface` with these methods: - `Init()` – Initialization code - `Update()` – Per-frame logic - `Draw()` – Drawing code - `Destroy()` – Cleanup Example: ```cpp #define BUILDING_SCRIPT_DLL #include #include class Script : ScriptInterface { void Init() { // Initialization } void Update() { // Frame logic } void Draw() { // Drawing } void Destroy() { // Cleanup } }; extern "C" ScriptInterface* SCRIPT_API GetScript() { Script* script = new Script(); return (ScriptInterface*)script; } extern "C" void SCRIPT_API DeleteScript(ScriptInterface* script) { Script* temp_script = (Script*)script; delete temp_script; } ``` --- ## Using the Math Library Create and draw points: ```cpp Graphite::Math::Point p({0.5f, 0.5f}, {1.0f, 0.0f, 0.0f}); p.drawPoint(); ``` --- ## Tips - Always implement all four methods - Use sandbox mode for safer editing - Use verbose mode for debugging - For edition use **sandbox mode** it prevents **segment fault** and **program crashes** at **runtime edition**. - **Sandbox mode** runs the ```Graphite -v ``` on fork. If program breaks it **doesn't stop whole program** just check if **script is changed**. - **Always** end **all threads** in script in ```Destroy()``` function. - When script is stable use **normal mode** for **performance**. - See `Examples.md` for more sample scripts --- For advanced scripting, see the API Reference and Tutorials.