Prev Previous Post   Next Post Next
Old 05-09-2016, 05:11 PM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default Tutorial: Building a GUI in Lua.

It seems like the majority of scripting questions these days revolve around how to build a GUI; understandable, since ReaScript doesn't have anything built-in to do it with. No matter though, it's not too hard.

We'll have to start with some fairly basic things, but by the time we're done you'll be able to do fancy stuff like this:



Disclaimer:
For the purposes of this tutorial, I'm assuming that the reader is familiar with the basics of Lua. If you aren't, I highly recommend X-Raym's videos for an introduction. Anyone who's watched his videos will also be familiar with the easier-to-read version of the ReaScript API documentation he put together, found here. It may not be up to date depending on when you read this, but personally I keep it open in a window all the time while I'm scripting.

Note: Writing these tutorials and the GUI library took a hell of a lot of time. If you find this useful, please consider clicking the donation link in my signature and tossing a few cents my way.

Table of Contents

1. Creating and maintaining a window
2. Colors
3. Drawing (part 1)
4. Text
5. Getting user input (part 1)
6. Introducing the LS GUI library
7. Example class - Button
8. Tables, classes, and methods
9. Working with strings
10. LS GUI in detail
11. Example classes - TxtBox, Sldr, and Knb
12. Using images
13. Having your script interact with the GUI elements

Other tips and tricks:

Automatically resizing text to fit a given space
Removing an element from the table

General Lua resources:

The Lua 5.3 Reference Manual
Lua-Users.org's tutorials
This cheat sheet and video that Garrick found
...or just our old friend Google. Searching something like "lua return multiple values from a function" will often get you a ton of results. If you're lucky, people will even put comments in their code. If you aren't lucky, you'll be stuck trying to make sense of paragraph-length jumbles of letters and symbols that look like this: (%a+):%s*(%d+)%s+(%a+):%s*(%d+)

Seriously. That's a thing in Lua. Dealing with strings of text gets scary sometimes.
__________________
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-19-2017 at 03:36 PM.
Lokasenna is offline   Reply With Quote
 

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 04:22 AM.


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