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

Couple of general script observations:

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

     blah 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:
Code:
local function Msg(str)
    reaper.ShowConsoleMsg( tostring(str) )
end

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

debug_enabled = true
Msg("this will always print")
dMsg("this will print")
debug_enabled = false
dMsg("this won't print")
__________________
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; 07-08-2018 at 09:12 PM.
Lokasenna is offline   Reply With Quote