I've reduced it to the following steps and minimal scripts:
- Run Script A.lua:
Code:
function loop() reaper.defer(loop) end
loop()
- Run Script B.lua (with the correct command ID for Script A.lua):
Code:
reaper.defer(function()
local cmd = reaper.NamedCommandLookup("command ID of script A here")
reaper.Main_OnCommand(cmd, 0)
end)
- Select "Terminate instances"
Maybe you could message the main script to terminate itself using a temporary extstate instead of re-running it?