Old 02-09-2017, 09:56 AM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,643
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.

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: 5,485
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: The vast, frozen wasteland of western Canadia.
Posts: 5,643
Default

Exactly. One less step for end users to worry about.
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 10:52 PM.


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