Scripting

From Luxology SDK wiki
Jump to: navigation, search

Scripting provides an alternative to writing C++ plug-ins for extending modo. Scripts can be used to automate or streamline processes for the user.

Contents

Supported Languages

modo supports four scripting languages:

  • Macros, the simplest script, which simply executes a series of commands in order.
  • Python, an object-based language with exception handling and deep integration into modo 701 through the new Python API.
  • Perl, a powerful language known for its string processing.
  • Lua, a popular embedded language often used in game development.

modo 701 introduces much deeper Python integration through the new Python API. This provides SDK-level access through Python, allowing full plug-ins to created without having to use C++. Macros, Perl, Lua and the older Python implementation only allow for fire-and-forget scripts, and you cannot create plug-ins with them.

Click the links above to see articles detailing how to use each language with modo.

Interpreter Lifespan

When a fire-and-script is executed, the interpreter for that language is spawned, the script is parsed and executed, and the interpreter is destroyed. Each interpreter exists only for the life of the executing script, and does not persist beyond that. This ensures that each interpreter has its own unique state.

For the Python API, there is a single application-wide interpreter that all Python plug-ins are loaded into. This is also used by the Command History viewport when it is set to Python mode.

Support Commands

Each scripting language has its own series of extensions that allow them to interact with modo. For the most part, these focus on executing and querying commands.

There are a few commands that exist primarily for use by the scripting system.

  • query, used to query ScriptQuery interfaces.
  • Dialog commands, used to open system dialogs and choice simple dialogs.
  • User Values, used to store script state in the config and provide basic user interfaces for scripts.
  • app.undoSuspend, which can significantly reduce memory usage for large operations at the expense of being able to undo them.

Examples

Examples for the various scripting languages can be found in the Scripting Examples category.

More Information