simvx.core.script¶
ScriptManager — file-based class script loading for nodes.
Scripts are standard Python classes that extend the node’s type. ScriptManager
imports the module, finds the matching class, and swaps node.__class__ so
the node gains the script’s methods (ready, process, etc.).
Inline scripts (exec-based) are preserved for backward compatibility with demos.
Public API: ScriptManager.load(node, project_dir) ScriptManager.unload(node) ScriptManager.reload(node, project_dir) ScriptManager.exec_inline(node) ScriptManager.load_tree(root, project_dir)
Module Contents¶
Classes¶
Static manager for loading/unloading file-based class scripts on nodes. |
Data¶
API¶
- simvx.core.script.__all__¶
[‘ScriptManager’]
- class simvx.core.script.ScriptManager[source]¶
Static manager for loading/unloading file-based class scripts on nodes.
- classmethod load(node: simvx.core.node.Node, project_dir: str = '') bool[source]¶
Load a file-based or embedded script onto node.
For file-backed scripts: resolves
node.scriptas a path relative to project_dir, imports the module, finds the class that best matches the node’s type, and swapsnode.__class__.For embedded scripts: registers source with EmbeddedScriptFinder, imports it, and applies the same class swap.
Returns True on success, False on error (logged, not raised).
- classmethod unload(node: simvx.core.node.Node) None[source]¶
Restore the node’s original class, removing the script behavior.
- classmethod reload(node: simvx.core.node.Node, project_dir: str = '') bool[source]¶
Reload a node’s script (re-import module, re-swap class).
Preserves Property values across the reload.
- classmethod exec_inline(node: simvx.core.node.Node) None[source]¶
Execute a node’s inline script string via exec() (backward compat).
- classmethod load_tree(root: simvx.core.node.Node, project_dir: str = '') list[simvx.core.node.Node][source]¶
Walk root’s tree: load file-based scripts, then exec inline scripts.
Returns list of nodes that had file-based scripts loaded (class swapped), so the caller can invoke
ready()or other lifecycle methods.