Lua Controller (mlys.lua)
mlys.lua, available in Modalys for Max environment only, is a controller that lets you write pieces of Lua script for static instrument construction (including 3D finite elements) or also real time control. Lua scripts are compiled on-the-fly with C language execution speed. The aim of mlys.lua is to provide as much flexibility as ModaLisp within Max' real time environment.
🚧 This section is still under construction and will be improved over time. Many examples can be found in the Modalys for Max package.
Modalys for Max syntax and Default Values
The mlys.lua controller can be created in Max using the following Lisp syntax:
[mlys.lua 2 3 @name MyLua @update 0.01]
The 'mlys.lua controller takes the following arguments:
- update: the update rate in seconds. 0 means every sample and -1 automatic.
- name: the variable name.
Double click the mlys.lua object to open the text editor. Close the editor to validate any changes. ⚠️Don't forget to rebang your object in order to reflect the changes.
Here is the minimal situation for your lua script:
require("tools") function initialize() -- This function (do not change its name!) will be run just once. You can put any initialization code here! end function update() -- This function (do not change its name!) is run according to the *update* parameter (0=every sample) -- Create your code here. The return value can be passed to a controller or a point-output. -- --optional: you can return as many values (comma-separated) as there are outlets. Ex: --return x,y end
The mlys.lua controller is similar in essence to the Expression controller but has some definite advantages:
- Lua is much more powerful in essence, yet simple to learn;
- Lua has some very interesting object-oriented capability;
- Lua is a widespread language, with a large community;
- The API code in Modalys is much lighter and easier to maintain, whereas the Expression controller is based on llvm, a project that is completely oversized for it...