Q:\REAPER 7.01-2\REAPER 7.01-2\Scripts\ck.lua:1: module 'js_ReaScriptAPI' not found:
no field package.preload['js_ReaScriptAPI']
no file 'Q:\REAPER 7.01-2\REAPER 7.01-2\lua\js_ReaScriptAPI.lua'
no file 'Q:\REAPER 7.01-2\REAPER 7.01-2\lua\js_ReaScriptAPI\init.lua'
no file 'Q:\REAPER 7.01-2\REAPER 7.01-2\js_ReaScriptAPI.lua'
no file 'Q:\REAPER 7.01-2\REAPER 7.01-2\js_ReaScriptAPI\init.lua'
no file 'Q:\REAPER 7.01-2\REAPER 7.01-2..\share\lua\5.4\js_ReaScriptAPI.lua'
no file 'Q:\REAPER 7.01-2\REAPER 7.01-2..\share\lua\5.4\js_ReaScriptAPI\init.lua'
no file '.\js_ReaScriptAPI.lua'
no file '.\js_ReaScriptAPI\init.lua'
no file 'Q:\REAPER 7.01-2\REAPER 7.01-2\js_ReaScriptAPI.dll'
no file 'Q:\REAPER 7.01-2\REAPER 7.01-2..\lib\lua\5.4\js_ReaScriptAPI.dll'
no file 'Q:\REAPER 7.01-2\REAPER 7.01-2\loadall.dll'
no file '.\js_ReaScriptAPI.dl
local jsapi = require("js_ReaScriptAPI")
local gui = jsapi.GUI()
-- Define script functions
function script1()
-- Script 1 logic
reaper.ShowConsoleMsg("Script 1\n")
end
-- Create buttons
local buttons = {
{
x = 50,
y = 50,
width = 100,
height = 30,
label = "Script 1",
action = script1
},
}
-- Main loop
function mainLoop()
local char = gfx.getchar()
if char == 27 or char == -1 then
return -- Close window or press 'Esc' to exit loop
elseif char == 1 then -- Left mouse button clicked
local mouse_x, mouse_y = gfx.mouse_x, gfx.mouse_y
handleClick(mouse_x, mouse_y)
end
-- Clear the entire window with light blue color
gfx.set(0.7, 0.9, 1, 1)
gfx.rect(0, 0, gfx.w, gfx.h, true)
-- Draw buttons
for _, button in ipairs(buttons) do
gui:Button(button.label, button.action, button.x, button.y, button.width, button.height)
end
gfx.update()
if char ~= -1 then
reaper.defer(mainLoop) -- Defer main loop
end
end
-- Start main loop
mainLoop()
local buttonColor = {52, 55, 60}
for i, script in ipairs(scripts) do
local button = GUI.createElement(
{
name = "SCRIPT_"..i,
type = "Button",
x = 60,
y = 30 + (i-1) * 30,
w = 200,
h = 25,
caption = script.name,
color = buttonColor, -- 添加颜色参数
func = function()
load(script.code)() -- 使用 load 函数执行代码字符串
end
}
)
layer:addElements(button)
end