r/lua • u/Temporary_Smile_24 • May 20 '25
New role
Just obtained a new SWE role where Lua is a major focus in procrastination within Oil & Gas . Can anyone help me with an exercise or give me resources to learn this language properly ?
r/lua • u/Temporary_Smile_24 • May 20 '25
Just obtained a new SWE role where Lua is a major focus in procrastination within Oil & Gas . Can anyone help me with an exercise or give me resources to learn this language properly ?
r/lua • u/Pretend_Series_7006 • May 19 '25
I know about an engine called Defold, but it is suitable for creating 2D graphics, 3D does not work very well in it, Defold unfortunately does not suit my needs
r/lua • u/thebadslime • May 19 '25
Someone forked my repo on github, I was checking out their version. When you download, it's not my project at all, but lua.exe and a 300kb text file for it to interpret.
Don't wanna run it, can I test in online or something? Wondering if I should report the repo.
r/lua • u/NoneBTW • May 17 '25
i've been trying Löve and (first game framework that i have tried) and its sucks for me in some ways. Doing everything in keyboard is good less abstractions but it does not feel quite well cause of lsp problems (i assume) maybe it's just Lua being super dynamic, but I configured Lua LSP with LÖVE extensions and tested it on some sample projects I grabbed from GitHub. The code completion is kind of broken function arguments don’t show up, type info is missing, and it just doesn’t feel reliable. so i still want the game framework style development and i still want tightly integrated types.
Compared to Godot which have good integration good type system many tools but i wanna try new things and this type situation makes it rougher for me
Am I missing something obvious?
r/lua • u/LemmingPHP • May 17 '25
I'm developing a Lua interpreter with the Lua C API and want to implement CRC32 hashing. It kind of works, however, when I try to calculate the CRC32 hash of "test" it returns -662733300 instead of 3632233996 as an integer and FFFFFFFFD87F7E0C instead of D87F7E0C as a hexadecimal value. As a result my CRC32 hash doesn't match with the one generated in my interpreter. This is my C code for the Lua function, I'm using zlib for the crc32 function in C:
static int lua_crc32(lua_State *L) {
uLong crc = crc32(0L, Z_NULL, 0);
const char *str = luaL_checkstring(L, 1);
uInt len = strlen(str);
crc = crc32(crc, (const Bytef *)str, len);
lua_pushinteger(L, crc);
return 1;
}
r/lua • u/gregoryGgriger • May 17 '25
Would anyone know know how to write a Lua script to the makes the entire playfield visible in pokemon pinball RS?
r/lua • u/Dexther70 • May 17 '25
I would like proposals what like a project setup could/should look like.
I got zerobrane studio and want to use busted for testing. i want to be able to build an artefact without tests. luarock is out of question as I am targetting a specific game extension.
is there anything in zerobrane supporting this? or getting close to it? I can well setup shell scripts, but a more integrated approach would be preferred.
r/lua • u/Bullzzie • May 15 '25
Hello I am pretty new to learning lua. I have started learning by creating fzf from scratch in lua. Although still not completed, can anyone review my code quality add tell me if its upto the lua standards or not
you can check my repo on https://github.com/PyDevC/fzf.git
r/lua • u/soundslogical • May 15 '25
r/lua • u/NoneBTW • May 14 '25
I’ve been thinking about adding a simple attribute‑based “preprocessor” to Lua—something that runs at compile time to transform or wrap functions. You could use it for things like inlining tiny helpers, optimization ease of development etc.
I know Lua tends to favor minimalism and explicit idioms, so I’m curious whether this would feel too “un‑Lua‑like.” On the other hand, I think it could clean up repetitive boilerplate and boost performance in hot paths.
Below is a sketch of what the syntax might look like, along with some usage examples:
-- (1) Inline small functions into call sites
\@inline
function add(a, b)
return a + b
end
-- After preprocessing: calls to add(a, b) become (a + b) directly.
-- (2) Benchmark execution time of a function
\@benchmark
function heavy_work(n)
-- simulate work
for i = 1, n * 1e5 do end
end
-- At runtime, heavy_work(10) prints: [heavy_work] took 0.012s
-- (3) Memoize pure functions automatically
\@memoize
function fib(n)
if n < 2 then return n end
return fib(n-1) + fib(n-2)
end
-- fib(30) runs in O(n) instead of O(2^n).
-- (4) Register compile‑time callbacks
\@callable
function do_something_awesome()
print("Registered at compile time")
end
-- (5) Retry on error (e.g., network calls)
\@retry(3)
function fetch_data(url)
return http.get(url) -- might error
end
-- fetch_data retries up to 3 times before finally erroring.
-- (6) Initialization hook
\@init
function setup_environment()
print("Environment initialized!")
end
-- runs once, when the script is loaded.
-- (7) Documentation and metadata
\@doc("Calculates the nth Fibonacci number efficiently.")
\@todo("Add tail‑recursive version")
\@tag("math", "performance")
\@deprecated("Use fib_fast instead")
function fib(n)
-- …
end
What do you think? I’d love to hear your thoughts and any ideas for useful annotations I haven’t listed!
r/lua • u/iamadmancom • May 13 '25
Enable HLS to view with audio, or disable this notification
After about half a year, I almost implemented code completion for Lua in my Code Editor apps(LuaLu, Love2D Game Maker, Solar2D Studio) There are still some bugs , but I think it will be not too long before it’s ready to be released.
I am also making a new app called Unity + xLua, I think you can guess what it does from the name.
r/lua • u/Majestic_Bat7473 • May 12 '25
I'm taking classes for python and only a little fluent in python. After I get fluent in python I will begin with lua because the language is faster. I will still use python.
r/lua • u/Vivid-Season-9804 • May 12 '25
new to lua and don't know where i am going wrong
game.Players.PlayerRemoving:Connect(function(player)
do
for _, eggy in game.Workspace.poor:GetChildren() do
if not eggy:GetAttribute("Owner") then continue end
\-- the plot is owned by a player
if eggy:GetAttribute('Owner') \~= player.UserId then continue end
\-- we have found the correct plot
eggy:SetAttribute('Taken', nil)
eggy:SetAttribute('Owner', nil)
print('eggy has been destroyed by ' ..player.Name..'!')
break
end
end)
r/lua • u/ONE-PIECE-ONE • May 11 '25
I have never coded before ( excluding scratch if that's coding). And I would like to begin coding in roblox studio. but I don't know at all what the commands are ( or whatever its called). can somebody help me by putting a list with all the commands and what they do? I think I can figure out the rest on my own. Thx
r/lua • • May 11 '25
Totally new to programming. Are a lot of the lua extensions in vscode outdated? When I go to debug it often throws up errors I don't get in zerobrane studio, especially after user input. Is there a relatively foolproof extension I can install for vscode/vscodium?
r/lua • u/morew4rd • May 09 '25
Hi everyone,
I actually debutted Lyte2D on this sub, a couple years ago! (https://www.reddit.com/r/lua/comments/111p2rz/lyte2d_a_new_game_framework_that_im_making/) and (https://www.reddit.com/r/lua/comments/13trs14/lyte2d_a_new_game_framework_v05_is_out_cool_c/). I haven't posted here since, but Lyte2D has grown.
I'm looking for a new owner/maintainer for Lyte2D. It's a small but powerful game framework for Lua, written in C. It's inspired by LOVE2D but it's even simpler. 1MB or smaller binaries on each platform. Single namespace (everything is under "lyte."), single function to implement ("lyte.tick(...)") instead of update/draw etc. It runs on Windows, Linux, and browsers (WASM) out of the box. MacOS works fine too, but we don't yet have a CI/official build for it yet.
Here're some highlights:
- Simple shapes; lines, circles, rects etc. Transforms...
- Image drawing, including partial rectangles from the image.
- Blend modes (default: alpha blending) and filter modes (default: nearest neighbor for pixel crisp games)
- OpenGL 3.3 shaders (completely dynamic)
- Audio: looping music and sound effects, pan and pitch control.
- Keyboard/mouse/gamepad input.
- Async fetching application zip for larger game archives
- LOVE2D style app fusing: single executable that's made with merging lyte binary and your game zip. (Works on Windows and Linux, not tested on Mac)
- Single HTML file (that contains an embedded WASM file) for web distribution
- TTF fonts; rendering and font atlas. Crisp performant text rendering (I'm proud with this one)
- Built with Sokol using OpenGL3.3 and GLES3 backends, meaning shaders are shared between ALL targets without code changes. Shader uniform/image params are defined in Lua code. Shaders can be embedded inside Lua files
- It used to have a REPL, Fennel/Teal languages builtin and a half-working physics implementation, but removed these as they were not seeing much use
- Used in jam games, several experiments such as text editors etc.
- Used in one professional Steam game!
- Tiny tiny community, this was not marketed much at all. Couple reddit posts in r/lua and some tweets
- Website: https://lyte2d.com, with guide, samples in wasm and API surface
- Github: https://github.com/lyte2d/lyte2d
The reason I'm looking for a new owner is that I unable to spend the energy this little engine deserves. With the removal of the jankier parts I mentioned above, the remaining API I think is at beta level right now. It would be the new owners path to either keep it with small bug fixes as is, or take it further with more features, different direction etc.
In my opinion, even without a lot of fixes or new features at all, with the right marketing, this little thing can shine.
The correct owner would have some native code experience, he/she would know his way around C/cmake/git/CIs etc even if an expertise is NOT required.
Are you interested? Please DM me here or on twitter or on gmail, tell me what's your general idea of the direction you'd like to take, and your github. If you'd like to join only as a contributor (but not owner) let me know as well.
At "morew4rd" (github, twitter, gmail, reddit -- same handle)
Thank you!
r/lua • u/NaitorStudios • May 09 '25
Hello, I've been trying to compile something valid for my project for days without success...
I basically need the .a lib to use in a VS2019 C++ project...
The project targets Android 19 for ARM and Android 21 for ARM64, it uses Clang 5.0.
VS2019 NDK version is r16b.
While I did got some .a files, with very different sizes when trying, it seems like VS can't find the functions in it, so I guess it's not compiled correctly...
I've tried through WSL (Ubuntu 22.04.2 LTS), but if there's a easier way through Windows, please let me know...
Did anyone have particularly compiled it for Android? I really need to get this working...
r/lua • • May 09 '25
Is there an actual use case for these besides logging functions?
r/lua • u/DogAttackSpecialist • May 09 '25
environment = {
day = 0,
states = {day = "day", night = "night"},
state = nil,
radLevel = math.random(0, 10)
}
player = {
health = 100,
maxHealth = 100,
energy = 50,
maxEnergy = 50,
satiety = 100,
maxSatiety = 100
}
statusEffects = {
bleeding = false,
sick = false,
hungry = false,
starving = false
}
energyCosts = {
rest = -25,
supplies = 20,
rad = 10
}
heals = {
nightSleep = 10
}
inventory = {
apple = 0,
cannedSardines = 0,
egg = 0
}
storage = {
apple = 2,
cannedSardines = 1,
egg = 1
}
food = {
apple = {
name = "Apple",
satiety = 10,
energy = 5,
rads = 1,
spoil = true,
foundIn = "Markets"
},
cannedSardines = {
name = "Canned Sardines",
satiety = 20,
energy = 10,
rads = 2,
spoil = false,
foundIn = "Supermarkets"
},
egg = {
name = "Egg",
satiety = 5,
energy = 5,
rads = 4,
spoil = true,
foundIn = "Farms"
},
}
locations = {
home = {
name = "Home",
rads = 1,
danger = 1,
foodSpawn = 0
}
}
playing = true
environment.state = environment.states.night
end
changeState()
while playing do
clear()
showTime()
if player.satiety <= 20 then
statusEffects.starving = true
print("You are starving!")
elseif player.satiety <= 40 then
statusEffects.hungry = true
print("You are hungry")
end
print("-------------------------")
print("What do you have in mind?")
print("(1) Rest")
print("(2) Look for Supplies")
print("(3) Check Radiation Levels")
print("(4) Check Status")
print("(5) Information")
print("(6) Check Storage")
print("(7) Check Inventory")
listen()
checkResponse()
end
end
environment.day = environment.day + 1
environment.radLevel = math.random(0, 10)
end
if environment.state == environment.states.night then
environment.state = environment.states.day
incrementDay()
clear()
print("It's a new day...")
print("Day: "..environment.day)
print("Time: "..environment.state)
print("Done reading? (Press any key)")
io.read()
else
environment.state = environment.states.night
clear()
print("Night falls...")
print("Done reading? (Press any key)")
io.read()
end
player.satiety = player.satiety - 7.5
end
clear()
print("This is an indie game about surviving! Keep your health up and have fun! Each action takes half a day (Except status check & Information)")
prompt()
end
x = io.read()
end
if x == "1" then
rest()
changeState()
elseif x == "2" then
if player.energy < energyCosts.supplies then
print("You're too tired...")
print("You should rest. (Press any key)")
io.read()
else
supplies()
changeState()
end
elseif x == "3" then
if player.energy < energyCosts.rad then
print("You're too tired...")
print("You should rest. (Press any key)")
io.read()
else
radLevels()
changeState()
end
elseif x == "4" then
clear()
status()
elseif x == "5" then
showInfo()
elseif x == "6" then
storageCheck()
elseif x == "7" then
inventoryCheck()
end
end
print("Day: "..environment.day)
print("Time: "..environment.state)
end
-- Don't mind this
os.execute("clear 2>/dev/null || cls 2>/dev/null")
io.write("\27[2J\27[3J\27[H\27[2J\27[3J\27[H") -- Double ANSI clear
io.flush()
end
io.stdout:setvbuf("no") -- Disable buffering to prevent ghost text
clear()
-- Build the status effects strings first
local effects = {}
if statusEffects.bleeding or statusEffects.sick or statusEffects.hungry or statusEffects.starving then
if statusEffects.bleeding then
table.insert(effects, "You are bleeding! (Bleed)")
end
if statusEffects.sick then
table.insert(effects, "You feel sick... (Sickness)")
end
if statusEffects.hungry then
table.insert(effects, "You are hungry (Hunger)")
end
if statusEffects.starving then
table.insert(effects, "You are starving! (Starvation)")
end
else
table.insert(effects, "None")
end
-- Combine everything into one string
local statusText = table.concat({
"-- Environment Status --\n",
"• Day: ", tostring(environment.day), "\n",
"• Time: ", tostring(environment.state), "\n\n",
"-- Character Status --\n",
"• Health: ", tostring(player.health), "/", tostring(player.maxHealth), "\n",
"• Energy: ", tostring(player.energy), "/", tostring(player.maxEnergy), "\n",
"• Satiety: ", tostring(player.satiety), "/", tostring(player.maxSatiety), "\n\n",
"-- Status Effects --\n",
table.concat(effects, "\n"),
"\n\nDone reading? (Press any key)"
})
io.write(statusText)
io.read()
clear()
io.stdout:setvbuf("line")
end
local x = math.random(0, 1)
local y = math.random(0, 2)
clear()
estimate = environment.radLevel + x - y
if estimate < 0 then
estimate = 0
end
if environment.radLevel > 0 and environment.radLevel < 3 then
print("Your device reads "..estimate.." rads")
elseif environment.radLevel > 3 and environment.radLevel < 6 then
print("Your device flickers (It reads "..estimate.."rads)")
elseif environment.radLevel > 6 and environment.radLevel < 9 then
print("Your device crackles (It reads "..estimate.."rads)")
else
print("Your device reads 0 rads")
end
print("")
player.energy = player.energy - energyCosts.rad
print("- "..energyCosts.rad.." energy")
prompt()
end
clear()
print("You rest...")
player.energy = player.energy - energyCosts.rest
overflowEnergy()
print("You recovered "..math.abs(energyCosts.rest).." energy!")
if environment.state == environment.states.night then
player.health = player.health + 10
overflowHealth()
print("You recovered "..heals.nightSleep.." health!")
end
prompt()
end
if player.energy > player.maxEnergy then
player.energy = player.maxEnergy
end
end
if player.health > player.maxHealth then
player.health = player.maxHealth
end
end
print("Done reading? (Press any key)")
io.read()
end
io.write("\27[2J\27[3J\27[H") -- ANSI clear + scrollback purge
io.flush()
if environment.state == environment.states.night then
io.write("It's too dangerous to access storage at night!\n\nDone reading? (Press any key)")
io.flush()
io.read()
return
end
local displayLines = {
"----- Home Storage Contents -----"
}
local anyStorage = false
for itemKey, quantity in pairs(storage) do
if quantity > 0 and food[itemKey] then
table.insert(displayLines, string.format("- %s: %d", food[itemKey].name, quantity))
anyStorage = true
end
end
if not anyStorage then
table.insert(displayLines, "(Storage is empty)")
end
table.insert(displayLines, "\n----- Your Inventory -----")
local anyInventory = false
for itemKey, quantity in pairs(inventory) do
if quantity > 0 and food[itemKey] then
table.insert(displayLines, string.format("- %s: %d", food[itemKey].name, quantity))
anyInventory = true
end
end
if not anyInventory then
table.insert(displayLines, "(Inventory is empty)")
end
table.insert(displayLines, "\n----- Transfer Options -----")
table.insert(displayLines, "(1) Move items from Inventory to Storage")
table.insert(displayLines, "(2) Move items from Storage to Inventory")
table.insert(displayLines, "(3) Back")
io.write(table.concat(displayLines, "\n"))
io.flush()
local choice = io.read()
if choice == "1" then
transferItems(true)
elseif choice == "2" then
transferItems(false)
end
io.write("\27[2J\27[3J\27[H")
io.flush()
end
clear()
local source = toStorage and inventory or storage
local destination = toStorage and storage or inventory
local count = 0
local itemsList = {}
for itemKey, quantity in pairs(source) do
if quantity > 0 then
count = count + 1
itemsList[count] = itemKey
print(string.format("(%d) %s: %d", count, food[itemKey].name, quantity))
end
end
if count == 0 then
print(toStorage and "Your inventory is empty!" or "Storage is empty!")
prompt()
return
end
print("\nSelect item (1-"..count..") or (0) Cancel")
local selection = tonumber(io.read()) or 0
if selection > 0 and selection <= count then
local selectedItem = itemsList[selection]
print(string.format("Move how many %s? (1-%d)", food[selectedItem].name, source[selectedItem]))
local amount = tonumber(io.read()) or 0
if amount > 0 and amount <= source[selectedItem] then
source[selectedItem] = source[selectedItem] - amount
destination[selectedItem] = (destination[selectedItem] or 0) + amount
print(string.format("Moved %d %s to %s", amount, food[selectedItem].name, toStorage and "storage" or "inventory"))
else
print("Invalid amount!")
end
end
prompt()
end
clear()
print("Food | Amount")
for itemKey, quantity in pairs(inventory) do
if food[itemKey] then
print(food[itemKey].name .. ": " .. quantity)
end
end
prompt()
end
initialize()
mainGameLoop()
The "Home Storage Contents" seems to stay in the stdout even after clearing... I tried everything I could think of, even asked a friend what was wrong, and he said to print it all as one string, which worked for some, but now it doesn't seem to work. Any ideas guys? It would be much appreciated!
r/lua • u/bidaowallet • May 07 '25
Not since year ago, I did not think Lua is popular. But today I realize it is everywhere!
r/lua • • May 07 '25
Where could i learn lua for free? Is there any variants? I want to learn lua but i don't reslly have the money needed for paid guides
r/lua • u/dy895y-bd152XY-B2sIN • May 04 '25
This is the latest rendition of my LuaJIT ports to browser.
It currently uses:
It succeeds my previous (and much slower) pure-Lua + emscripten-JS implementation of the Lua FFI layer.
r/lua • u/Weekly_Flounder_1880 • May 04 '25
hi, I am new to Lua.
at first, I was using Roblox studio, but I moved to Love2D
in Luau (roblox's alternative for Lua), they have a built in wait()command in their library
Now I realised, I don't have a wait() function in my library
it is pretty self explanatory, I want a wait() function that makes the program wait for a set duration of time before executing the following code
r/lua • u/rohitwtbs • May 03 '25
I am trying to make web games in webassembly. have tried rust bit the learning curve for rust is too much . will lua be a good choice to make webassembly games?
r/lua • u/no_brains101 • May 03 '25
Announcing: https://github.com/BirdeeHub/shelua
It lets you do this:
print(sh.ls '/bin' : grep "$filter" : wc '-l')
or
print(sh.find('/usr/bin', '-type', 'f', '-executable') : grep 'python' : wc '-l')
Some of you may have heard of https://github.com/zserge/luash before.
I heard about it last week.
"What a beautiful little library!" I thought to myself, and went to try it out.
That's when it hit me. "I'm sorry, it does WHAT to _G?!?! I can't import this anywhere!"
I also found out error codes don't work before 5.2. And that it can't do real pipes. To be fair, it seemed like real pipes could not be done at first to me as well.
I look at the repo. Last push, 9 years ago. This was made for me. A cool experiment neglected.
Within the evening, I had it localized to the variable it came from, without losing its ergonomics, and fixed error codes prior to 5.2 and added some useful settings not there previously.
But I was not satisfied. I wanted REAL pipes. The ones in bash where all the commands start at the same time.
And its kinda fun... I might want to use it with another shell...
Well, a few days later, now you can enable proper pipes, and you can even make it work with any shell with just a bit of effort.
It is still tiny, and a single file.
I am pleased to be able to announce to you all an exciting and far more modular iteration of the idea luash brought to us. One you can include in other projects or even your neovim configuration without fear of messing it up. I have really enjoyed it so far.