View Single Post
Old 03-02-2017, 12:51 PM   #8
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

In case you haven't found it yet (you probably have), a basic for loop in Lua looks like this:
Code:
for i = 1, 10 do
  reaper.ShowConsoleMsg("i = "..i.."\n")
end
You can also provide a third number to use as the 'step' amount:
Code:
for i = 10, 1, -1 do
 ...
end

for i = 1, 10, 0.5 do
 ...
end
Also useful is being able to exit the loop early:
Code:
for i = 1, 10 do
  reaper.ShowConsoleMsg("i = "..i.."\n")
  if i == 8 then
    break
  end
end
__________________
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