Script: mock interpreter

function getClientInfo()
    return {
        name = "interpreter",
        author = "pncss",
        versionNumber = 1,
        minEditorVersion = 0
    }
end

function main()
    local code = SV:showInputBox("input", "input command", "return 1 + 1")
    local f = load(code)
    SV:showMessageBox("result", tostring(f()))
    SV:finish()
end

This script was sketched based on the fact that SynthV uses the Lua 5.4 implementation.
Being able to use file I/O was predictable because it has already been used.
local fh = io.open(f0, “rb”) // Synthesizer V Pro(琴葉茜・葵)でAIきりたんを真似るスクリプト - 雑談 - ルモーリン

Additionally, I could expect that there is the function executing string as a code, as well due to the language characteristics of Lua.
The key is “load”(loadstring in 5.1), and it was successfully run in SynthV.

Perhaps using this, you can experiment with scripts more easily by implementing an interpreter inside.

Video: Script: Mock interpreter - YouTube

3 Likes