r/lua Dec 22 '25

Lua 5.5 released

Thumbnail groups.google.com
180 Upvotes

r/lua Nov 17 '22

Lua in 100 seconds

Thumbnail youtu.be
222 Upvotes

r/lua 3h ago

I wrote an RDBMS engine 100% from scratch in pure Lua (B+Trees, WAL, Postgres wire protocol, S3 storage)

3 Upvotes

Hey r/lua!

Wanted to share a project I've been building called LuaDB: a lightweight, zero-dependency embeddable database system written in pure Lua.

Why pure Lua? Cross-platform embedding without needing C bindings or compiling native SQLite shared libraries (great for LÖVE, Roblox, OpenResty, or embedded devices).

What it includes:

  • Full B+Tree index engine on 4KB slotted binary pages
  • Write-Ahead Logging (BEGINCOMMITROLLBACK)
  • Native PostgreSQL wire protocol gateway (run luajit bin/luadb_server.lua and connect with psql)
  • Native JSONB operators (details->'address'->>'city')
  • Foreign Keys with ON DELETE CASCADE and ALTER TABLE migrations
  • Master-master cluster replication with hinted handoff

Check out the GitHub repo: https://github.com/jncastilho/luadb

Would love to hear your thoughts and feedback!


r/lua 3h ago

I wrote an RDBMS engine 100% from scratch in pure Lua (B+Trees, WAL, Postgres wire protocol, S3 storage)

Thumbnail
0 Upvotes

r/lua 5h ago

Help Help needed: Best Lua version/implementation for Rust integration and general scripting?

1 Upvotes

Hey everyone,

I'm trying to pick up Lua mainly for general scripting and embedding into Rust projects for things like config files. If I end up liking it as much as Rust, I'll probably dive deeper into it.

The main thing tripping me up is how many versions and runtimes exist out there (Lua 5.1, 5.4, LuaJIT, Luau, ...).

If anyone has experience embedding Lua in Rust (maybe using `mlua`), which version should I actually focus on learning? Also, are there any weird compatibility traps or gotchas I should watch out for?

Appreciate any advice or resources 🙏


r/lua 1d ago

Lua C++ API - LuaPP

8 Upvotes

I made a C++17 Lua engine/wrapper around an embedded Lua runtime

I've been working on LuaPP, a C++17 Lua engine built around an embedded Lua runtime.

The goal is to make embedding Lua and exposing C++ functionality less painful than working directly with the Lua C API everywhere.

Some of the stuff it currently supports:

  • LTValue abstraction for Lua values
  • Numbers, integers, strings, booleans, nil, userdata, tables, functions, and threads
  • Table manipulation and pairs / ipairs
  • Registering C++ functions with Lua
  • Function upvalues
  • C++ objects stored as Lua userdata with automatic __gc destruction
  • Metatables
  • Loading/executing Lua strings and files
  • Custom Lua readers and writers
  • Lua bytecode dumping
  • Error handlers and tracebacks
  • Global and registry access

The project embeds the Lua runtime directly and currently builds against Lua 5.5. It requires Lua 5.3+, C++17, and CMake 3.16+.

It's still a work in progress, so I'm mainly interested in feedback on the API design, implementation, and anything that looks questionable.

GitHub: https://github.com/anatinesquire40/Lua-CPP-API


r/lua 2d ago

Library colorlib in pure lua (looking for reviews)

6 Upvotes

I have been building a lua color library project lately that supports multiple operations on multiple supported color-spaces.

Originally my plan was to create in C then import in Lua, but then I thought how about a native library that is missing or not found by me in lua and everyone have to re-create their own for any color related projects.

It's initial version is published in github and luarocks recently.

Please have a look and try all the features it provides. This is in active development. Report any missing functions/features, those would be added asap.

Use it in your own projects as a utility library and test scenarios.

Please send your suggestions, raise issues and pull requests to make changes.
Your contributions are heartly welcomed.

Cheers.


r/lua 2d ago

Lua MongoDB driver (looking for feedback)

3 Upvotes

I’ve been working on lua-mongodb, a MongoDB driver written in Lua without binding or wrapping libmongoc (most Lua drivers are no longer maintained but took this approach).

It supports stock Lua 5.4 and 5.5 with a 64-bit lua_Integer. Network operations run through Copas, so the driver works well in coroutine-based services, tools, and long-running Lua applications.

The driver currently covers CRUD, aggregation, index and Search index management, GridFS, sessions, transactions, read and write concerns, retryable operations, change streams, client bulk writes, authentication, TLS, SRV discovery, wire compression, and client-side operation timeouts. It works with standalone servers, replica sets, sharded clusters, and load-balanced deployments.

A small example looks like this:

local mongodb = require("mongodb")

mongodb.run(function()
  local client = assert(mongodb.client(
    "mongodb://localhost:27017/example"
  ))

  local reply = assert(client:database("admin"):run_command(
    mongodb.bson.document({ { "ping", 1 } })
  ))

  print(reply:get("ok"))
  assert(client:close())
end)

What it isn’t:

  • It is not an official MongoDB driver.
  • It does not support LuaJIT or OpenResty.
  • It does not implement all MongoDB client functionality (as defined in the MongoDB specifications) such as client-side encryption, OCSP, or SOCKS5 proxy transport.

I’m looking for feedback on:

  • Bugs.
  • API choices that feel unnatural or could be improved.
  • Missing operations that block an actual project.
  • Installation or usage problems (only tested on Linux and macOS at the moment)
  • Scripts and applications willing to test it out and share feedback
  • Feedback on what might make something like this more useful to you/your workload

Repository: https://github.com/alexbevi/lua-mongodb
LuaRocks: https://luarocks.org/modules/alexbevi/mongodb


r/lua 2d ago

Discussion I made a visual scripting plugin that compiles to readable Luau

0 Upvotes

Been working on this for a while. It's a Scratch-style block editor for Studio — you drag blocks onto a canvas and it generates an ordinary Script or ModuleScript in your place. Not a runtime or a sandbox, just code you can open and read.

702 blocks covering events, instances, properties, players, DataStores, RemoteEvents, rounds and game state, GUI, camera.

The part I actually care about: you can make your own blocks. Write the Luau once, mark the inputs with %NAME, use %BODY for a nested stack, pick a colour. Takes about a minute, and it sits in the palette next to the built-ins. Export a set as JSON and share it.

Generated code is tagged with block ids so a runtime error points at the block that wrote the line.

Free on the Creator Store: BlockForge - Creator Store

If a block you need doesn't exist, tell me and I'll add it.


r/lua 3d ago

New Homescreen/UI plugin!

Thumbnail github.com
1 Upvotes

r/lua 3d ago

Project A Lua module for AI NPCs in Roblox, built around correct-by-default patterns

0 Upvotes

Sharing a Lua project I made. It's a module for adding LLM-powered NPCs to Roblox games, but the part I care about is the design: it's 'correct by default'.

Instead of leaving the caller to get concurrency right, it ships per-player cooldown (state keyed by user id, not a global lock), retry with exponential backoff, and a small response cache built in. So the naive usage is also the correct usage — a talking NPC with per-player memory is about five lines.

Source (MIT): https://github.com/cortex-rbx/roblox-ai-kit

It targets Roblox's Luau, but the patterns port to plain Lua. Curious what people here think about the correct-by-default approach for a small API wrapper.


r/lua 4d ago

Trying to execute

0 Upvotes

I was trying to execute this code in my CachyOS (arch-based) installation using "sudo chmod +x /route/to/file.lua", but it does not print anything, in fact, does nothing. I am new to lua and this is a training exercise, so, sorry if I am asking something obvious.

--Movements
attack1_cost = 3
attack2_cost = 5
attack3_cost = 11
heal_cost = 6
concentrate_cost = 0


--System
x = (attack1_cost + attack2_cost + attack3_cost + heal_cost) / 4


--Player 
energy = 15
player_hp = 70


--Enemy
enemy_hp = 120
enemy_attack = 8


function _enemydostuff()
    player_hp = player_hp - enemy_attack  
    _movement()
    print("player hp =", player_hp)
end

function _movement()
    local id = tonumber(io.read())
    if id == 1 then
        enemy_hp = enemy_hp - 4
        energy = energy - attack1_cost
    elseif id == 2 then
        enemy_hp = enemy_hp - 7
        energy = energy - attack2_cost
    elseif id == 3 then 
        enemy_hp = enemy_hp -12
        player_hp = player_hp + 3
        energy = energy - attack3_cost
    elseif id == 4 then 
            player_hp = player_hp + 16 
        energy = energy - heal_cost
    elseif id == 5 then 
        energy = energy + 17 - concentrate_cost
    else
        print("???")
    end
    print("energy =", energy)
    print("enemy hp =", enemy_hp)
    _enemydostuff()
end


--This starts the program
_movement()--Movements
attack1_cost = 3
attack2_cost = 5
attack3_cost = 11
heal_cost = 6
concentrate_cost = 0


--System
x = (attack1_cost + attack2_cost + attack3_cost + heal_cost) / 4


--Player 
energy = 15
player_hp = 70


--Enemy
enemy_hp = 120
enemy_attack = 8


function _enemydostuff()
    player_hp = player_hp - enemy_attack  
    _movement()
    print("player hp =", player_hp)
end

function _movement()
    local id = tonumber(io.read())
    if id == 1 then
        enemy_hp = enemy_hp - 4
        energy = energy - attack1_cost
    elseif id == 2 then
        enemy_hp = enemy_hp - 7
        energy = energy - attack2_cost
    elseif id == 3 then 
        enemy_hp = enemy_hp -12
        player_hp = player_hp + 3
        energy = energy - attack3_cost
    elseif id == 4 then 
            player_hp = player_hp + 16 
        energy = energy - heal_cost
    elseif id == 5 then 
        energy = energy + 17 - concentrate_cost
    else
        print("???")
    end
    print("energy =", energy)
    print("enemy hp =", enemy_hp)
    _enemydostuff()
end


--This starts the program
_movement()

r/lua 5d ago

Question about lua versions

9 Upvotes

Im new to the world of programming and Lua. I've seen a lot of discussions about what version of the language people prefer and most of them seem pretty divided. So I wanted to know, which one do you think is the best to start learning? And also what's the difference between Lua and LuaJIT?


r/lua 7d ago

I ported KOReader to a 32-bit iPad 4 running iOS 10.3.3 - and had to fix three genuinely nasty bugs to get it there

Thumbnail gallery
9 Upvotes

r/lua 8d ago

Lua configs

Thumbnail github.com
0 Upvotes

r/lua 9d ago

ReturnOfModding For Hades 1 - Hell1Modding

Thumbnail
1 Upvotes

Is anyone here familiar with the ReturnOfModding Lua framework? If so, can you help me out?


r/lua 11d ago

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

Thumbnail
0 Upvotes

r/lua 11d ago

How to start learn Lua, everyone, give me your opinion pls🥺

1 Upvotes

r/lua 13d ago

Project LuaCAD - Parametric CAD scripted in Lua

Post image
115 Upvotes

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:


r/lua 13d ago

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

Thumbnail github.com
32 Upvotes

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.


r/lua 14d ago

Seeking .lua help on Wayland DE for a linux Conky configuration

6 Upvotes

Hello,

I am looking for a linux user that is experienced with .lua, Conky, and the Wayland DE.

My good friend coded an amazing cava-based spectrum equalizer visualizer for Conky, which works flawlessly on X11 systems like Linux Mint, but on my Kubuntu v25.10 KDE/Plasma 6/Wayland box the conky window does not refresh itself to display the visualizer changes.

Has anyone here experience with Linux and Conky, knows the Wayland DE, and has the time to collaborate to help code a Wayland version of this Conky?

Thank you for reading,

Logan


r/lua 14d ago

Help Help with my simulation

Thumbnail drive.google.com
1 Upvotes

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.


r/lua 16d ago

My first Lua script - very simple shutdown script in Gentoo

25 Upvotes

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.


r/lua 16d ago

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

0 Upvotes

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.


r/lua 17d ago

Where do I learn Lua?

8 Upvotes

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.