r/lua

LuaCAD - Parametric CAD scripted in Lua
▲ 157 r/lua+1 crossposts

LuaCAD - Parametric CAD scripted in Lua

LuaCAD models solids in Lua rather than the OpenSCAD language, with operator overloading for CSG (a + b, a - b, a * b). It ships with a CLI and a desktop app, including a preview area and a text editor.

It’s fully open source and you can find the repo here: https://github.com/ad-si/LuaCAD

I've always been a big fan of OpenSCAD, but the SCAD language itself is unfortunately quite cobbled-together and is a very poorly designed programming language.

LuaCAD takes all the good parts of OpenSCAD and combines them with Lua. It has now completely replaced OpenSCAD for me, and I think it provides a better experience than OpenSCAD for all use cases. I'd love to hear any reasons why LuaCAD won't fully replace OpenSCAD for you!

Tech stack:

u/adwolesi — 3 days ago
▲ 0 r/lua+1 crossposts

How to Obfuscate and Protect Source Code of My Love2D game?

I don't want people to steal the code and republish my game because I put a lot of work into it and I want to protect my own hardwork/intellectual property.

I can't find any good lua obfuscators online, does anyone know any good methods to obfuscate source code. I want to be able to remove comments, have random variable names and remove whitespaces

reddit.com
u/Inesh23 — 3 days ago
▲ 44 r/lua+1 crossposts

My game engine, cookie engine made in odin, using lua as a scripting language

Hello everyone, I spent the last 2 months learning about creating a game engine, I also wanted to learn the odin language and I thought this was a good start, I also made it use lua as a scripting language similar to usagi engine and love2D, this is a hobby project so expect poor code and rough decisions.

I should also mention it is not vibe coded but I did ask questions to ai assistants but not use ai to write code, I know what the code does so I have learned from it.

I was inspired by usagi engine when I saw a post of the engine I got interested in making my own but I didnt have a language that is similar level to c/c++ I remember odin from a youtuber who made a game using the language and decided on using that.

github.com
u/Dragon20C — 5 days ago
▲ 2 r/lua

Help with my simulation

Hello, I'm new to Lua and, after reading some documentation, I am trying to do basic a simulation of work and property. I have a base script for each worker and a base script for each workstation, but I need help to code how the worker decides in what workstation work and how the workstation's capacity to hold workers on a day is changed by that. I wrote some notes on the scripts, I think that they clarify very well where I need help. The link is to a folder with the scripts.

drive.google.com
u/Salt-Discount-1381 — 6 days ago
▲ 0 r/lua

I'm interested in creating my own programming language. How could I write it in Lua?

I've seen a few posts about this, but none had enough information for me. Hoping you guys could help :)

Edit: Also suggestions for syntax changes are welcome. This language doesn't really solve too many problems, mainly makes some things faster, examples are else [expression] instead of elseif [expression], or . instead of closing brackets {}.

Here's the example.

https://preview.redd.it/ctkfww7ck1jh1.png?width=605&format=png&auto=webp&s=71e0073fd7ff774d2166f750a3aae38e8965ae01

reddit.com
u/Microsoft-Spyware-11 — 8 days ago
▲ 9 r/lua

Where do I learn Lua?

So I'm very interested in learning Lua, essentially for modding existing games and maybe doing basic scripts, but every tutorial I find about Lua on YouTube is only about Roblox. Where can I lear this language? I prefer reading guides than whatching videos.

reddit.com
u/Salt-Discount-1381 — 9 days ago
▲ 6 r/lua

Did you try to write a game server in Lua?

Hello. Recently, I've been thinking about writing my own game server in Lua. However, I didn't find many server examples in the internet, not to mention how incomplete they are. I'd like to ask the following things:
- Possibility of writing a game server in Lua.
- Libraries, which are used to write a game server in Lua
- The difficulties that may occur when writing a game server in Lua.

Thank you for your answer.

reddit.com
u/dywoqq — 9 days ago
▲ 20 r/lua

My first Lua script - very simple shutdown script in Gentoo

I just wanted to post my entry into Lua and celebrate beginners. I don't really know if I will commit myself to coding regularly, but I'm pleased with Lua regardless.

I found the Lua online book ( https://www.lua.org/pil/contents.html ) very easy to read and learn from.
I'm still near the start but many other languages make the very start extremely boring or tedious to read through. The Lua documentation and this book are nice to walk through and use.

I'd like to note my script below starts with the #! script line. I never even realized you could do that. I've never really dabbled in bash scripting or other kinds of system scripting. But the Programming in Lua book starts with it, and got me to think about it as I went through my day. It's that kind of tutorial design that sparks ideas and excitement.

I also recently installed Hyprland in my gentoo system, that sounds advanced but I have no clue what I'm doing and still working on it. But I found the lua config file nice to work in, and it got me to look at the language a bit more.

I should clarify, I actually have a Bachelor's degree in Computer Science, I know you'd think I should be able to learn any language and I should be coding daily. But frankly I cannot and I do not, I struggle to get myself to write code outside of work (and my work was mostly Javascript/CSS).

Last year I was layed off and I spent the year frantically trying to get another development job, and dipping my toe into various tech stacks that companies claim they want. I made little progress and ultimately failed to secure a job. The software job market is worse then ever here in North America and it's time I move away from it. I'm joining the military, and I'm lucky I even have the opportunity to. But with my exit of the industry, I'm now more interested than ever in having fun with programming in my spare time. I'm embarrassingly slow learning, but I'm happy to take it easy.

Below is my extremely simple script to run OpenRC's shutdown command.
I've noticed different init systems use slightly different shutdown commands, with different flags and expectations. I only use Gentoo sometimes, as my second distro, so I always forget the specifics of OpenRC's shutdown command. I realized today I could write a Lua script right in my /usr/bin/ folder and call it the name of my custom command!

I watch Youtube playlists late at night on my desktop computer, from bed. I lay in bed with wireless, or sometimes long-wired headphones, and watch Youtube to get comfy and fall asleep. I don't want to have to get back up, ruining my near-sleep state. So I always run shutdown with a delay.
In SystemD, this is just sudo shutdown 'minutes'. But OpenRC wants a halt and Poweroff flag added, otherwise it just.. sits on a black screen all night.

So this is /usr/bin/myshutdown (reddit seems to be eating tabs and spaces so it's not tabbed sorry)

#!/usr/bin/lua
minutes = tonumber(arg[1])
if not arg[1] or not minutes then
print("myshutdown requires number of minutes!")
else
os.execute("sudo shutdown -hP " .. arg[1])
end

Despite how simple it is, I did actually end up troubleshooting some stuff.
I ended up re-learning that Lua just doesn't care about null (or "nil") values and I can just call stuff without worrying of a crash.
I also had to look up simple things like finding array length (strangely non-direct answers, saying to use 'getn' but arg doesn't work with it... etc....).
I found out arg has nothing in it if you don't put any arguments in it, that may sound obvious but some languages put the program name in arg[0] (of course Lua has no 0... right?).
I discovered all args are of type string, and require translation, here I found tonumber but I didn't look into any better ways to do that.
There were likely a few other things, I spent a couple hours writing this, somehow.

I'm now wondering if I can write one script, that detects which init system is running and runs the appropriate flags. Or maybe there's some other way to call shutdown that would be convenient.

I think I tried a distro, or maybe FreeBSD (?) before that wouldn't let me delay shutdown. I can't remember what it was, but I'd be curious to find out more.

Ultimately I don't really write software for fun, and a lot of the issue is coming up with an idea I even care about. This was an exciting change of pace, a fun idea and a very quick outcome. It makes me want to try more, and Lua's ease-of-use is to blame lol.

Thank you to the Lua community and developers.

reddit.com
u/SleepyGuyy — 9 days ago
▲ 0 r/lua+1 crossposts

What do you consider to be "the Rust of Lua dialects"?

I'm currently working on a Rust to Lua and Luau compiler (not to be confused with mlua, which is Lua integration for Rust); inspired by CSharp.Lua.

I figured that it would be beneficial to add a dialect that's closer to Rust, so that it could be used to compile code faster, or into a VM in a more true-to-form fashion. The idea is that you could compile to said language, and have pretty much the same functionality as you would with Rust, except for maybe CPU/GPU backends, as a heuristic.

There are lots Lua dialects: Terra, MoonScript, Teal, Pallene, just to name a few; and I can see a valid argument for each of these being a candidate for "the Rust of Lua dialects", but I don't have much experience with most of these, especially in the context of Rust-ability (oxidation?). Hence, I would be happy to hear your opinions and sentiment on which dialect is best for this position. thx :]

reddit.com
u/2What2WhoNowHuh — 10 days ago
▲ 18 r/lua+1 crossposts

Kanvon - 2D Mesh Support

Kanvon.com Now supports 2D meshes to create animations, could easily animate with using lua scripting to follow a specific object

u/nycgio — 11 days ago
▲ 4 r/lua

Where can I buy a book to learn lua?

For some reason I cant find a book to learn lua on that looks legit, its all "learn lua in 24 hours". I want it to be physical. Thanks!

reddit.com
u/batatolah — 10 days ago
▲ 122 r/lua+2 crossposts

Awesome now supports Lua 5.5

Happy to share that the Lua 5.5 support PR was recently merged into Awesome! (https://github.com/awesomeWM/awesome/pull/4110). The Archlinux AUR -git package now builds successfully as well.

This was much more than a single PR in Awesome. It ended up being a months-long effort involving updates to several internal build dependencies and CI tooling. I contributed patches here and there across the ecosystem, alongside many other people working on Lua 5.5 compatibility.

I updated my config last week. Here is a fun screenshot using awesome-client to pop a notification that show the running Lua _VERSION variable.

u/aire-one — 14 days ago
▲ 0 r/lua+1 crossposts

Roblox developer concept pitch: C>, a C++ fork

What C> is

While this proposal uses the design name C>, the language could ultimately be called anything (such as C++U or Luau System-Level Extensions or something). The core architectural principles and demographic benefits remain identical either way.

C> is a high-performance systems language designed to integrate directly inside Roblox Studio as an optional dropdown scripting choice.

To the developer, C> looks and feels exactly like standard C++—you type the exact words, formatting, and keywords you already know (like int, for, and standard pointers). However, the backend is a hyper-optimized compiler engineered by Roblox.

It takes that standard text and applies elite data-oriented compiler rules. For desktop and console targets, it aggressively unrolls loops and pins active data straight into the CPU's ultra-fast internal hardware registers. This expands the compiled binary file sizes by roughly 2.5x to achieve absolute, bare-metal hardware execution speeds that match modern languages like Zig and Jai, completely bypassing traditional C++ performance baggage.

Right now, Roblox has been trying to appeal to an older and more mature audience, like releasing more 18+ games. But by allowing more mature developers to join faster, we can easily increase our average player age.

Why Roblox Needs C>.

We have Luau coders in our system already, but if we made C>, we could bring the biggest audience of programmers in the world, allowing for people to get into the system faster and make more hit games with less "brainrot."

Currently, many low-effort games exist because Luau is easy enough for children to copy-paste. Bringing in professional C++ programmers who understand deep software architecture will cause the platform's game quality to skyrocket. Furthermore, once this C> compiler infrastructure is stable, it can expand over time. Releasing other upgraded languages (like PythonU or Java> and stuff) over years will gain Roblox even more coverage and even more players globally.

How C> Interacts with Luau and fixes lag.

The key to maximum performance is variety and choice. C> doesn't replace Luau; they tag-team the engine just like Roblox's internal architecture uses C++ and Luau together today. Many games on Roblox currently have performance issues even on PC. Bee Swarm Simulator, for instance, has to perform many calculations which causes lag. If Onett wanted to fix the lag, he could learn C> and recode the game in C> to fix lag for PC players.

Even better, a developer could use both: using Luau for packet delivery and C> for advanced local calculations to reach max performance. The Luau Package: Luau acts as a quick and nimble packet and data deliverer. When data moves across the internet, it compiles down into tiny, anonymous binary opcodes (~300 bytes) to fly across the network with zero bandwidth lag The C> Muscle: The millisecond that microscopic packet hits the client's PC or console, the local engine decompiles it and explodes it into ultra-optimized, cache-aligned machine instructions to handle heavy onboard calculations like rendering, massive AI simulation matrices, and complex local physics.

Shooting down opposing theories.

A common corporate counter-argument is that a 2.5x binary file size increase will ruin loading speeds and performance for players on mobile phones or weaker devices. This theory fails for two major reasons: Hardware Evolution: With new phones and new Wi-Fi versions releasing regularly, that problem won't be a very big problem for people playing C> games on mobile. Technology is moving too fast for file size to remain a bottleneck. Natural Audience Segmentation: For older phones and weaker devices, we don't need to worry about that either. These C> games would be for an older audience, an audience with better devices, and more importantly, PCs.

Developers will not be dumb. They will try to appeal to kids on mobile by learning and coding in Luau to keep their files small and instant. Meanwhile, devs that are going to make an 18+ game will want to make it in C> for better targeting and optimization. Kids will still be playing the slop Luau games that are made for them, while our older PC players will be able to take full utilization of their system to play the AAA hits that they crave.

reddit.com
u/Idontknow1084 — 14 days ago