Coder.Haus | Scripting With Lua in Roblox – First Impressions
We're a family of geeks who live to design scalable software and hardware solutions. We focus on solid, simple designs focused on industry good standard practices.
ITIL, SLA, Service Level Agreement, Change, Change Management, Development, Coding, Programming, Javascript, Java, Kotlin, Arduino, RaspberryPi, RPi, Android, VSCode, Hacker, Maker, Infrastructure
16148
post-template-default,single,single-post,postid-16148,single-format-standard,ajax_fade,page_not_loaded,,qode-title-hidden,qode_grid_1300,qode_popup_menu_push_text_top,qode-content-sidebar-responsive,qode-theme-ver-17.2,qode-theme-bridge,disabled_footer_bottom,wpb-js-composer js-comp-ver-5.6,vc_responsive

Scripting With Lua in Roblox – First Impressions

I recently took my first real dive into coding scripts in Roblox. The game platform uses the scriptiong language Lua to allow developers access to its API. Here’s what I found after a short time at it.

Everyone has an opinion.

Roblox API developers seem to be opinionated, from what I gather in comments and code snippets in their API documentation as well as videos. This is fine for me, even though there’s more than one way to do it (TMTOWTDI), to borrow a phrase from PERL, I like when the basic pieces of a language guide me. I want to focus and innovate on my solution, that’s where the fun is, unless there’s some good architectural reason to implement a piece of code in some non-standard way. In short, I’m good with copy pasta so I can focus on the big picture, and the Roblox devs give us a large array of code to accomplish this.

The IDE

The tools from Roblox in their IDE are lacking. Like, seriously lacking. Autocomplete doesn’t seem complete, for one. Autocomplete can’t pick up the context of a variable and show suggestions for that variable. There are only a few key commands, but those that I find I use often like duplicate line, are missing with no way it seems to add them. There aren’t any macros in the IDE to expand to the code snippets they suggest in their documentation, which would be a nice add to save me from copy/pasting from their site. Because I should have the documentation I need in the IDE, and not have to move back and forth between different tools to get the information I need.

I did try, weakly, to use VSCode for my scripting. I installed a few plugins, including that for Rojo, and gave it a short go. What I found was the code complete plugins were kind of nice, and I liked that I could have all of my keyboard shortcuts and things available. I have to work on this flow, because I feel it will work great including being able to push scripts to github. That will be my focus this week, to export scripts that I have in my current game and use VSCode exclusively to code. The pain in this flow comes with having to import scripts into the game to test. This is where Rojo comes in.

Rojo, you evade me

Rojo is a tool to “link” Roblox studio to the dev tools of your choice, so you can use your favorite toolset to do your scripting and push to a repo that gets compiled into a Roblox game, or directly link from Roblox Studio to run a game you’re coding elsewhere. I only tried to install the Rojo VSCode extension and took about 30 minutes to test it out. I didn’t get very far, and the documentation directly in the project is seriously lacking. In the end I didn’t search too far, and just gave up. I think Rojo will give me the rest of what I want, using good tools and integrating with Roblox Studio to make the workflow easy. I just have to plan time to dive into Youtube, github, etc to find examples that show me what I’m actually supposed to do to use the tool.

Lua, the language

I’m a big fan of the simplicity of the language. It doesn’t get in the way of the targeted API, and gives me enough of what I need to get the job done. I cut my teeth in languages like MUMPS, so this feels a bit like home. I really enjoy Lua treating functions as first class citizens, closures, minimal typing. Overall I feel like I could bump Lua into my top 5 favorite languages to work in.

Wrap up

Right now I’m definitely a Roblox scripting noobie. I’m writing code for functionality that I feel is already part of the API, and based on the thoughtfulness of the API design probably is. For folks who are just dipping their toes in programming, or who have some experience programming but haven’t done it for any length of time, this is where any amount of time is spent with a language. One you know one, or a few, languages you know most of the basic constructs – for loops, if, while, typing, functions, etc. It’s everything else that takes time – specific APIs, quirks of the language and tools, finding your workflow, how to achieve good architecture.

For me, getting beyond newcomer means writing the code as I know how, doing some research, and updating code as I learn more about the API. I’m never ashamed to not know something, ask questions, and figure things out weeks or months later while working on some other piece of code. I know I’ll come back to rewrite portions of my code, so I make sure I use good practices (like SOLID) to make this easy to do.

I have some work to do, to really get into a good flow with the tools and API for writing Roblox scripts. In particular I have to research more about Rojo and other tools, to find out if I can use them in the flow I imagine. So far I’m having fun and looking forward on moving forward on this journey!

Tags:
, ,