Old 02-09-2017, 09:56 AM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default Script: Run Lua script in debug mode

It occurred to me that we might all benefit from a single, easy-to-use action for enabling debug messages, rather than distributing separate debug versions of our scripts or asking users to edit the script themselves. So:

Lokasenna_Run Lua script in debug mode
Lokasenna_Run last Lua script in debug mode
(also on ReaPack)

All it does is prompt the user to select another script, sets a global variable, debug_mode, to true, and then runs the script they chose. If your script is set up to check for debug_mode then it can start printing debug messages with no fuss on the end-user's part.

For example, most of us use some variation of:
Code:
function Msg(str)
  reaper.ShowConsoleMsg(str)
end
Just change it to this, and you're good to go:
Code:
function Msg(str)
  if debug_mode then reaper.ShowConsoleMsg(str) end
end
The second script is a replacement for "ReaScript: Run last ReaScript (EEL or Lua)". Why? The last script is stored in REAPER.ini, which ReaScripts can access, but the filename is overwritten as soon as you run the Debug Mode script, so the Debug Mode script can't see what the actual last script was.

Hopefully this is useful for someone. Cheers.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate

Last edited by Lokasenna; 06-09-2017 at 02:50 PM.
Lokasenna is offline   Reply With Quote
Old 02-09-2017, 02:07 PM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

You mean like in my scripts ?

REAPER-ReaScripts/X-Raym_Stutter edit selected media items.lua at master · X-Raym/REAPER-ReaScripts

Code:
function Msg(value)
    if console then
        reaper.ShowConsoleMsg(tostring(value) .. "\n")
    end
end
:P
X-Raym is offline   Reply With Quote
Old 02-09-2017, 02:17 PM   #3
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Exactly. One less step for end users to worry about.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:32 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.