How to Make a Reminder Plugin for GrandMA3 Using Lua

Hey lighting folks! The following is the transcript from my YouTube video, This Easy Reminder Plugin Will Change Your Life!!

If you're new to Lua or need a refresher, I think you'll also enjoy my Lua for GrandMA3 Tutorial series. Please check out my channel, From Dark To Light, on YouTube, and you can find the code to go along with my tutorials here on GitHub.


Ever been in the middle of a set and see something you can't change in the moment but need to fix before the next show? Have you made a mental note and just never found it again? Since real notes work better for me too, I found a way to set a reminder on the console and this one will jump up and remind you on its own.


Hello lighting people, welcome back to my YouTube channel, or if it's your first time learning with me, I'm so happy to see you here. Today I'm going to show you a reminder plugin I developed so that I could set reminders for myself at any time while programming so I can get everything done that I need to before go time.


I'll just give you a quick overview of these plugins that I've already written out because I feel like that is a better use of time than sitting here writing them all out. So I'm going to start with this one I have called “Set Reminder.” You are going to need two plugins to achieve this because you're going to need one to set the reminder and one to display it. I have two different versions to show you. To start off with, I have Set Reminder right here and it's a pretty short simple plugin. 18 lines of code, that's pretty simple. We basically just have a message box where you put in your title, one input that you can put your ReminderText into. I set a max text length of 1000 because I've had issues with it not letting me input more than two characters if I don't set a max text length to something.

Then I put two commands, I put “Set Reminder” and “Cancel.” That way you have the option to just cancel out without doing anything.

Then we have a simple if statement. It says if this message box result is 1, so the user clicked Set Reminder, then we take the value from the input and we store that into ReminderText. If ReminderText is not already nil, then we concatenate the current ReminderText with a new line and the value we just entered. It will have multiple reminders added on rather than replacing it. Then we have an agenda cue in MA3 call this other plugin every 15 minutes and if there's nothing currently set for reminder, then nothing will happen. Again, it's a really simple one. We just check “is ReminderText nil” and if it's not nil, then we display the ReminderText. Then we have two options to remind me again or “I got it.” If you click I got it, then ReminderText gets reset to nil. Otherwise, ReminderText is still active, so the next time the 15 minute reminder comes up, you'll see it. Of course, you can pull up this reminder at any time. If you just call the plugin, then you can see it. That is pretty simple. 

That is the simplest one that lets you set a reminder that will go off in the next 15 minutes and it will repeat every 15 minutes, and I like that, but I created a more complicated one for my own setup at my church because I liked the idea of being able to set reminders for specific times. Like for example, if I'm in the middle of a service and I want to be reminded after the service is over or if I'm in the middle of rehearsal and I want to be reminded after rehearsal is over because I know I'm not going to deal with it before that. 


So I created one more like this, which is a bit more complicated obviously. But basically, we have a command table for each scenario. One scenario is no service and that has the options “remind me soon” or “cancel.” We have the option of we're in the middle of rehearsals. We have the options “remind me soon,” “remind me after rehearsal,” “remind me after service” or “cancel.” We have Sunday rehearsal because we have two services on Sunday. This one gives you the options to “remind me soon,” “remind me after rehearsal,” “remind me after service” or “remind me after second service” and we also have “cancel,” of course. Then, Sunday nine o'clock service, we have the options to “remind me soon,” “remind me after service,” “… after second service,” or “cancel.”

And the service one, which would get used during the 11 o'clock service as well as midweek services, says “remind me soon,” “remind me after service” and “cancel.” And then if the tables have not been reset, we reset these tables and this will make sense later on why I'm doing this, but at this point, instead of storing in a simple variable like this, I chose to use tables and you'll understand why in a minute. But then we check the time and if it's after 10:20 on a Sunday, then we reset the post-service reminder to be the post- 2nd service reminder. And then we go through this whole thing, which determines which command table to use based on what day and time it is. And this is a mitigated version. I have more options in my own plugin that I regularly use, but I built out the simpler version just for this video.

Then we go to actually getting to the reminder and we use the command table, which has been determined by the date and time, to determine what the commands are that are available. And then notice we use the same number for the same option every time. Right here we go, if the user said “number one,” then that's remind me soon. It sets the NextReminder table’s next empty value to the value that was input by the user. So we're not overriding anything. We're just adding the new reminder at the next index. And then if it was number two, that would be remind me after rehearsal, then it puts it in the PostRReminder table. If it was after service, we put it in the PostSReminder table. If it was after the second service, we put it in the PostS2Reminder table. And this is why we reset these tables because you have to have the table existing before you can try to insert something. So this sets the reminder at this point. You can set the reminder for whichever one you want. And that table now contains all the reminders you've set that haven't been deleted, obviously, in different table indices.


Then we go to the display reminder plugin and this one right here, so first off, when we call this one, rather than just calling plugin whatever, we give it an argument. And then once you get that argument, you go, okay, let's see, if the argument is “post-rehearsal,” then the current reminder should be the post-rehearsal reminder and we'll reset that to an empty table.

If it's “post-service,” that should be the post-service one. Same thing. If it's “post-service,” then if it's Sunday and it's before 11 o'clock, then I want to reset the post-service reminder to the post second service reminder. Otherwise, I'll reset it to empty braces.

And then the other option is if the reminder is “regular,” then we set it to the next reminder. And then because these are in tables, we have to now put them in a form that they can be rendered as a string. So we're going to look through all of the indices in the current table. And if ReminderText is nil, we set it equal to that text of the current table index.

And if it's not nil, then we concatenate it. I like to use two new lines in between. And then we will display the reminder.

And again, we have the options to remind me again, or I got it. And in this case, if you say that you want to be reminded again, then the next reminder is set to the current ReminderText. So pretty simple. And just to show you how that looks in in MA3, I have my agenda cues here and I just put in quotes what I want the argument to be. And then it will display that at the correct time. And so I can set the post-rehearsal one to be whatever I want, I can set multiple ones for different days. And anytime it calls the plugin with that argument, it is going to display the current reminders for that time. 


This argument, by the way, I'm sure you may have noticed I have an empty “display” one in here. And then I have this reminder. And then I have this reminder. I did talk about how that process works in my Lua for MA3 tutorials, Episode 10 video, which is about some miscellaneous stuff. But that's one of the things pretty important. You might want to go watch that video if you don't understand how this is working. And if you're trying to add multiple arguments in here, it's not going to work. And you do have to put this dummy in in order to be able to use the second one. 

And then the other thing is, anytime you are using time-based commands, which I love to do, they're super helpful, it does make troubleshooting a little bit more complicated. You could just replace this with something else for testing and be like, okay, this works. And then just make sure that generally your time commands are properly working. You just have to be aware that you can't fully test it in its final state until you get to that time. And so I've often had to put plugins into use without having

 troubleshooting them just because of how that works. And then I have to kind of go back and fix things later that didn't work.

Another thing I will say about the date and time things is that this ‘%X’ does give you the current time, but this is not accurate on a console. And I also talked about that in my Lua for MA3 episode 10 video, so go back and watch that one if you haven't, because this time I'm using just “os.date(‘%X’)” here right now in this one, but on a console, that would not be accurate because it shows you the UTC time when you use that function on a console. So in order to get the right time, I built a function that converts it. But definitely go watch that video if you're unsure about how that works.


The only other thing is, obviously when you are using this more complicated type of reminder plugin, what is going to happen is you're not going to be able to just call this and view the reminders without typing in a whole sentence, which I mean, obviously, yeah, you can do that. I don't love doing that. So what I did is I also built another plugin called “view active reminders” and I'm not going to show that one to you right now because I haven't written it out on this computer. But basically, all it does is it takes each one of these reminder tables, splits them up kind of like this, and then also puts a note in that “this is the next reminder, it has that reminder text, this is the post-rehearsal reminder, it has that reminder text,” and so on, and it just shows it to you. So again, that's pretty straightforward.


This reminder plugin has helped me a lot. And it's something that I actually just briefly touched on in a YouTube short that I published about, I don't know, a month or two ago. And somebody commented on that short was like, “hey, how do you do the reminder?” And I was like, “oh, yeah, that's a really helpful thing I should talk about.” So if you have any kind of like questions or comments of things that you would like to see videos on, either because I've mentioned them, or you just think they're interesting, definitely let me know. I'm totally open to it. And I do read my YouTube comments.

If you're having a question about this, definitely let me know because this is just a brief overview. I'm hoping that if you've watched my videos, this is all you need in order to be able to build it, but if you want to talk, we can talk. 

And that’s all I have to show you today, so I will see you in another video soon and I hope you have an amazing week! Go program something new for fun just because you can, and happy programming!

Comments

Popular posts from this blog

Lua for GrandMA3 YouTube Crash Course

Intro to Lua for GrandMA3