Haxe externs(bindings) for Reaper's Lua ReaScript variant, write your Reaper plugins in Haxe and compile to Lua for ReaScript.
Currently in Alpha, major changes may be made in the future
The Haxe externs are generated via the reascript2hx parser for lua documentation files provided by vscode-reascript-extension.
- Install Haxe
- Add HxReaScript to haxelib
haxelib git hxReaScript https://github.com/inc0der/HxReaScript - Create your
.hxmlfile addhxReaScriptas a library and target Lua.
# Main plugin class
-main Main
# Add hxReaScript as library
-lib hxReaScript
# Use vanilla lua to avoid pulling in other dependencies (unless you need them)
-D lua-vanilla
--lua bin/lua/main.luaThe generated classes expose the ReaScript API directly. For more convenient
workflows, use the small handwritten helpers in reaper.ReaperTools:
import reaper.ReaperTools;
var track = ReaperTools.selectedTrack();
if (track != null) {
var name = ReaperTools.trackName(track);
}
ReaperTools.withUndo("Rename selected track", function() {
// Reaper edits go here.
});The generated externs can be replaced from reascript2hx without overwriting
these helpers.
The generator is a development-only dependency. After installing the Node development dependencies, regenerate the raw externs with:
npm install
npm run generate-externsThis updates only reaper/Reaper.hx, reaper/Graphics.hx, reaper/ImGui.hx,
and reaper/Types.hx. Handwritten helpers such as reaper.ReaperTools remain
outside the generated output.
Since it appears many of the C++ and Lua method names are similar this may be a good base to compile to the C++ ReaScript variant in future revisions.