Thread: ReaLauncher
View Single Post
Old 07-08-2018, 09:03 PM   #33
Human being with feelings
Lokasenna's Avatar
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,361

Couple of general script observations:

- Lua can do block comments rather than having to comment each line if you want:

     blah blah blah
- You should be able to use / as a file separator on both Windows and OSX without any trouble. Windows will quite happily let you mismatch them: C:/Users\\Me\\AppData/Roaming/Reaper/Scripts\\ReaTeam Scripts/stuff.lua

- Reaper has a function for getting values from an .ini if you want: retval, string = reaper.BR_Win32_GetPrivateProfileString( sectionName, keyName, defaultString, filePath ). Ignore the name; it should work on OSX just fine.

- You can wrap ShowConsoleMsg in a helper function to save a bit of typing, and having to remember the \n each time - in fact, GUI.Msg("my string") is ready to do it for you. You can also include the debug check in a helper rather than having to check each time:
local function Msg(str)
    reaper.ShowConsoleMsg( tostring(str) )

local function dMsg(str)
    if debug_enabled then reaper.ShowConsoleMsg( tostring(str) .. "\n" ) end

debug_enabled = true
Msg("this will always print")
dMsg("this will print")
debug_enabled = false
dMsg("this won't print")

Last edited by Lokasenna; 07-08-2018 at 09:12 PM.
Lokasenna is online now   Reply With Quote