r/lua

▲ 69 r/lua

Usagi Engine v1 Released - Simple Lua 5.5 2D game engine with live reload and cross-platform export

I made a small game engine called Usagi for prototyping 2D games as quickly as possible with Lua 5.5. It's free and open source and made with Rust + Raylib. I just released v1.0 yesterday and thought it'd be fun to share it.

Here's the project's homepage: https://usagiengine.com/

And you can view the source here: https://github.com/brettchalupa/usagi

The engine is used via a command-line, much like cargo. You can usagi init to create a new project. usagi dev to boot up the dev game that live reloads code and assets. And usagi export to generate cross-platform builds of your game for web, Linux, macOS, and Windows.

My motivation for creating Usagi was that I love using tools like Pico-8 and Love2D for prototyping and game jams. But I wanted a free and open source engine with a nicer developer experience. In particular live reload and easy web exports. Usagi embraces constraints and provides sensible defaults, like a pause menu with input binding, to try to help devs focus on the game rather than the ancillary parts of development.

Since the engine is open source, the hope is that if someone makes a prototype they want to turn into a larger commercial game, they can just fork the engine and customize it themselves, write more bits of it in Rust, and change the API as they see fit.

I'd love it if you check the project out and let me know what you think!

u/brettmakesgames — 1 day ago
▲ 24 r/lua

Is Lua fit to use for general, personal use scripting of basic things (as replacement for Bash)?

Sometimes I have to automate a basic task, such as running some commands on files in my music library, bulk renaming, moving things, etc; and like anyone, I tend to try and use Bash for things like that, because that's what I was taught. The problem is that I don't like Bash scripting at all and I have to look up the stupid syntax for every little thing every god damn time. From what I've seen, other shells aren't too much better in my opinion, and in general, I actually don't like relying on shell commands within my scripts for things that would be simpler in a 'normal' programming language.

I've tried using Python as a replacement, but I don't like having to make a venv. It's bulky and annoying. I'd like to just have one script file I can run in one command whenever and not have to go through hoops.

I've been eyeing Lua just because it sounds cool but I've never had a reason to actively learn it. Would it be fit for this usage? Or is it solely a language for "project use", so to say?

reddit.com
u/WorkingMansGarbage — 3 days ago
▲ 19 r/lua+2 crossposts

LjTools to generate LuaJIT bytecode for your programming language, now supports LuaJIT 2.1

github.com
u/suhcoR — 2 days ago
▲ 7 r/lua

What is a good first game to start off with learning scripting?

I’m currently on day 4 of learning Roblox scripting/Luau and I’ve been following a beginner tutorial series while also experimenting with my own scripts outside the tutorials. So far I understand basics like variables, loops, events, touch detection, humanoids, functions, conditions, and simple mechanics like kill bricks, speed boosts, transparency changes, etc. I’ve also started debugging my own scripts instead of just copying code.

I want to start making small projects to improve instead of jumping straight into my dream game too early. What would be a good first game/project to make that helps me learn scripting and game development fundamentals without being too overwhelming?

reddit.com
u/InsideComfortable295 — 3 days ago
▲ 26 r/lua+2 crossposts

I Hardly Know'er - Poker idle. 30-60 Min browser playable prototype, looking for feedback on the loop

Hi all, I'm looking for some feedback on my first game project. It's playable on itch.io. Everything is rough, this is a simple prototype to test some of the core loop but I would be really happy to hear some thoughts on the concept. Expect UI weirdness and the like.

The main theme is grinding online poker, jumping up in stake levels and all that. All the instructions are on the itch page

Thank you in advance, happy to answer questions and whatnot. This game has been in development for about 2-3 months.

Some things I'm looking for feedback on:

  • Anything that reads as a bug.
  • Does the grind hold for the playtime and how is the pace (30-60 min roughly for content present)
  • What would you like to see added or anything that doesn't make sense/detracts?
  • Any other feedback. Be as detailed as you like, what you like or didn't, etc

I hardly know'er - Poker Idler

u/Professional-Bed8052 — 3 days ago
▲ 0 r/lua

how much lua do i need to know in order to make my dream game?

sup, names Jack and i been recently dreaming of making my own roblox games after seeing my favorite youtuber making a viral one, i do find roblox studio familiar but i dont have former experience of scripting AT ALL! My plan is to watch tutorials, study them and then in 3-4 weeks when i have summer vacation i can spend those 1.5 months to make a game. How did you guys learn? Do you have any tips?

reddit.com
u/InsideComfortable295 — 4 days ago
▲ 26 r/lua

I only know Python. Python → Lua → Glua is this logical? How do I switch from Python to Lua?

u/vtf00 — 5 days ago
▲ 7 r/lua+1 crossposts

Do pullEvents behave differently inside FOR loops ?

Some context. I'm making an articulated arm with create Aeronautics controlled by computers.

3 motors to get maximum movement. Highly inefficient, cool as fck

My problem resides in the way i've been controlling the motors.
All 3 motors have individual computers with modems, all ready to recieve instructions from the main pc. They are supposed to receive an instruction, and sleep continuously while the motor is active, and only at the end of the movement will they send a reply to the main pc, which will trigger the next commands.
The arm is supposed to be slow, it's supposed to move only one motor at a time (intentional).
When i make a simple basic list of modem,transmits() ,the arm behaves as intended.

this proof of concept worked as intended

This above is a very simple instruction to make the arm move slightly. My problem was this was ugly and tedious to expand. So i made a much cleaner(?) and more customisable version that was supposed to make it MUCH more simple to make new movement prompts later down the line.

function movementControl(a)
  local actionCount = 0
  local directionValue = 0
  local turnorder = {{1,2},{5,6},{3,4},{1,2},{3,4},{5,6},{1,2}}

  for i, angle in ipairs(a) do
    if angle == 'forward' then
      directionValue = -1

    elseif angle == 'backward' then
      directionValue = 1

    elseif angle =='motorstart' then
      rs.setOutput("back",true)
      sleep(3)

    elseif angle == 'motorstop' then
      rs.setOutput("back",false)
      sleep(5)

    elseif type(angle)=="number" then
      actionCount = actionCount + 1
      modem.transmit(turnorder[actionCount][1],turnorder[actionCount][2],{angle,directionValue})
      sleep(0.1)
      modem.open(turnorder[actionCount][2])
      local event, side ,channel, replyChannel, message, distance = os.pullEvent("modem_message")
      modem.close(turnorder[actionCount][2])
      sleep(0.1)

    end
  end



end


local harvestwheat1 = {'forward',30,20,23,'motorstart',30,'motorstop','backward',23,20,60}
local harvestwheat2 = {'forward',100,20,23,'motorstart',40,'motorstop','backward',23,20,140}
local harvestcarrot1 = {'forward',110,70,47,'motorstart',20,'motorstop','backward',47,70,130}


movementControl(harvestwheat1)

Now the actual problem is that the os.pullEvent i do when in my for loop dont seem to actually pause the computer. The loop kinda just continues on without waiting for the response from the motors.
Is there a specificity to Lua that i'm not getting (not likely) ? is there a specificity that my not good at coding ass doesn't understand (much more likely) ?

Ty for the help, and if people have better ways of doing any of this i might cave in and just redo the code from scratch with some suggestions ><

local gear = peripheral.wrap("right")
local modem = peripheral.wrap("left")
modem.open(1)


while true do
  
  local event, side ,channel, replyChannel, message, distance = os.pullEvent("modem_message")


  gear.rotate(message[1],message[2])


  while gear.isRunning() do
    sleep(0.5)
  end
  modem.transmit(replyChannel,20,gear.isRunning())


end

bonus : this is the code im using on the pc at the motors.

reddit.com
u/Pillow51 — 4 days ago
▲ 14 r/lua+1 crossposts

Class: a tiny single-file OOP helper for Lua 5.1+

Hey !

I’ve been working on a small project called Class.

Basically, I wanted a lightweight way to write class-like structures in Lua without bringing in a full framework or making the code feel like it’s fighting against Lua’s style.

So I made Class: a single-file OOP helper for Lua 5.1+.

It’s meant to stay simple, readable, and easy to drop into a project. It supports things like constructors, private instance state, accessors, cloning, includes, and a few helper methods for debugging or operator behavior.

I know Lua already gives us all the tools to build these patterns ourselves with tables and metatables, but I wanted to wrap the repetitive parts into something clean and reusable.

I’d really appreciate feedback from people who write Lua regularly:

Does the API feel natural?
Is anything too “non-Lua”?
Are there edge cases I should handle differently?
Would you personally use something like this, or do you prefer rolling your own class system?

Here’s the repo:
https://github.com/Lost-Things-Studio/Class

Thanks for checking it out :)

u/Lower_Block_9427 — 4 days ago
▲ 447 r/lua+5 crossposts

I'm still working on my engine for PS1 games. More details in the comments.

u/CyaneCornix01 — 7 days ago
▲ 41 r/lua+1 crossposts

Just open-sourced my personal scraping engine: tiny self-contained binary with Lua scripting

I originally built it for myself because I wanted something extremely lightweight that runs in the background like it never existed. It's called SpyWeb.

It's designed to be "set and forget." I've had it running for months on my PC tracking job boards without a single crash or memory leak.

Specific features:

  • Zero Runtime: Self-contained ~7MB binary. No Python, Node, or Docker needed.
  • Low Footprint: Uses <5MB RAM at idle.
  • Lua Scripting: Use Lua to handle complex logic like custom headers, JS rendering, advanced monitoring, etc.
  • Hot Reloading: Change a config or Lua script and the job respawns instantly, no restarts.
  • Web Dashboard: Simple local UI to monitor scrape data in real-time.
  • Desktop Alerts: Built-in support for system notifications and webhooks.
  • Embedded DB: Built-in KV store so you don't need a separate database.
  • CDP Support: Controls any Chromium or CDP-compatible browser via Lua for JS-heavy sites.
  • Dual Mode: CLI for servers and a System Tray version for silent background runs.
  • Deduplication: Internal database ensures you never see the same result twice.

I just released the beta with CDP integration. If you need something that just sits in the background and sips resources while actually being maintainable, check it out.

Set up is very easy and straightforward: for server-side rendered pages, it's just a few lines of config (URL, selectors, fields). For JS-heavy sites, you can write a little Lua to launch a browser and drive the workflow.

You can check it out here: https://github.com/spyweb-app/spyweb

u/Additional-Elk-3712 — 6 days ago
▲ 1 r/lua+1 crossposts

Downloading Steam Games using Lua and Manifest

Hey everyone! I’m not really experienced with pirating or anything like that, but before I had a BeamNG manifest file and just dragged it into SteamTools, and it basically handled everything for me. The website I used to extract the files stopped working though, so now I’m not sure what to use anymore. I’m trying to do the same thing for FH6, but I can’t find any good websites or tools.

reddit.com
u/Ok_Current235 — 6 days ago
▲ 22 r/lua

I created a Lua port of the classic Turtle Graphics program, for learning purposes. Here's the prototype

For those who aren't familiar, Turtle Graphics came out of work in the '60s, '70s, and '80s by Seymour Papert, Wally Feurzuig, Cynthia Solomon, and others on the LOGO programming language. It teaches math and programming in a visual, intuitive, embodied way (long before those terms were marketing buzzwords).

Python ships with a version of turtle graphics which uses the TKinter UI library by default, but some great web versions exist, including pythonsandbox.com/turtle and WebTigerPython. YouTube has terrific examples of what you can make with the Python library.

I believe Turtle Graphics is (still) underrated as a learning and teaching tool for anything quantifiable. The original book associated with it, Mindstorms: Children, Computers, and Powerful Ideas is still worth reading and still ahead of its time. It's available online as a free PDF, from Papert's estate, at Bret Victor's worrydream.com and elsewhere. (I have no association with any of these projects).

This project is my first serious undertaking with AI-assisted engineering, but I'm reasonably pleased with it so far. There's a web-based version (Github) and a desktop port (Github) as well, for those who prefer their own IDE setup.

Both projects are roughly feature-equivalent but still under active development and a bit rough around the edges, as you can see.

I hope this project is useful to you, either now or in its future, completed state.

The Lua API is as close to the Python API as I can get it, although naturally there are some differences between languages. If you're already familiar with the Python library (or familiar enough with Python to understand some of the online turtle examples) this would be a good way to become familiar with Lua.

Happy coding!

EDIT: There's a wonderful, mind-bending textbook by Harold Abelson and Andrea DiSessa called Turtle Geometry: The Computer as a Medium for Exploring Mathematics that explains turtle coding in-depth, with a whole host of cool, trippy graphics and very readable pseudocode for implementing them. (Part of the inspiration behind this port is how closely Lua mirros the syntax of those examples and of some of the original LOGO design principles). It is also available free online via MIT's Direct reader.

Here are some Github gists with ready Lua sample code for some of the animations:

The "spiro" program

A general "polygon" program — one of my favorites.

luaturtle.com
u/microworlder99 — 6 days ago
▲ 0 r/lua+1 crossposts

Help pls with code

if btn(⬆️) then
grav=grav-1
if timer=0 then
grav=grav+1
timer=timer+4
else
timer=timer-1
end

reddit.com
u/Few_Letter_9286 — 7 days ago
▲ 5 r/lua

Storing references to lua types inside LuaJIT FFI types.

TIL: yes, this can be done. And yes, it is completely safe: you cannot cause UB with this.

local ffi = require("ffi")

--Declaring our ffi struct that will hold the data.
ffi.cdef([[
  typedef struct {
    void* data_ref;
  } LuaTable;
]])

--Can be any lua type stored on heap (table, function, thread, userdata).
local data = function()
  print("hello world")
end

--We get the actual address and store it in a lua number.
local data_ptr_id = tonumber(tostring(data):match("0x%x+"))

--The external storage. That's the only way to get the object back from C land.
local storage = {}
storage[data_ptr_id] = data

--(You can set __mode for this table so that it stores values weakly. But then all ffi structs wouldn't be able to "own" the data inside them.
--To actually own the data and correctly let go of it, you'd need to make a reference counter primitive, like a shared_ptr&lt;T&gt; in C++ or Rc&lt;T&gt; in Rust.
--This counter will also need to be an ffi struct so that we can set a ffi.gc() callback for it.
--The callback would do `storage[data_ptr_id] = nil`, but *only* when there are no longer any references to it. 
--So it basically lets go of the data and to let GC manage it. Remember that regular tables could also store our object!
--You'll need to make sure that each reference counter primitive (lets just call it Rc) holds a unique object, or, in other words, there can't be two Rcs holding the same object. 
--Otherwise, after any of them get freed, the object will get prematurely released.)

--Here's our ffi struct.
local table_ffi = ffi.new("LuaTable", ffi.cast("void*", data_ptr_id))

--And here's how we get it back.
local also_data = storage[tonumber(ffi.cast("uintptr_t", table_ffi.data_ref))]

--If the object's been collected by the GC already, we'll just get a nil, so no use after free opportunities.

--Enjoy!
also_data()
reddit.com
u/Polanas — 7 days ago
▲ 6 r/lua

no os.setenv and I wanted a vim.env polyfill. Made one.

https://github.com/BirdeeHub/lua-osenv feel free to use it too if you want.

It is 1 C file <250 lines, with a nice interface, use the makefile, luarocks, nix, or write the c compiler command to build, requires C compiler and lua.

Edit: now actually runs the tests on windows too

u/no_brains101 — 9 days ago
▲ 6 r/lua

Need help finding a developer for fivem

Hello everyone this is my 2nd post on this subreddit about this topic and got alot of responses but this post is slightly different

Currently I've been trying to hire a developer part time for a project of mine that has been in the works since May 2025 and development has been pretty slow currently as its just me and my friend who is developing the server and i wanted to make an update post honestly asking if anyone who is a developer would be interested on working with us for a small percentage, small payment per task/task list currently I'm putting in around $100-200 a month into the server for only a few months as i do not have much money and the main reason why I'm having issues with finding developers is i understand majority of developers now use ai but my goal with this project is to not have ai used at all when it comes to the coding for the server which does spend more time on creating scripts but i have had very bad experiences with vibe coders such as being scammed, the scripts made by AI cause numerous amount of bugs the list goes on. If this is something that interests you and would like to learn more about the project and goals please contact me on discord.

This post is NOT to throw shade at anyone who uses AI to code i just have had very bad experiences with AI.

Discord - naqs871

reddit.com
u/Altruistic-Living309 — 8 days ago
▲ 5 r/lua

Tips for beginners

So I was thinking about learning Lua to make a passion project that Ive been thinking about for a while and wanted to know if there’s anything I should know before hand that will make my experience easier.

reddit.com
u/DurianStill9448 — 8 days ago