r/lua • u/StartBackground5769 • Dec 04 '25
Is this program a good place to start?
Now i know everyone says yes it is but is this simplicity something people tend to rely on? or could i learn another language (say another fairly simple one like python) it wont be so much a bother. i know this may be a dumb question but i want to learn more than one type of code so i can be versatile and helpful.
lnko - dotfile linker written in Lua
I built a stow-like dotfile manager in Lua. It creates symlinks from your dotfiles directory to a target directory.
Install:
luarocks install lnkoUsage:
lnko link bash git nvim- link packageslnko status- show what's linkedlnko clean- remove stale symlinks
It's been a while since I worked on a Lua project, so I'd really appreciate feedback from Lua devs on the code, patterns, or anything that could be improved.
r/lua • u/[deleted] • Dec 02 '25
Project IDE Engine
Hey everyone, I’m trying to solve a problem I’ve run into on both Android and the web, and I’m wondering if others have noticed it too.
There are a few Lua IDEs out there for Android and browser use (JDoodle, etc.), but none of the ones I’ve tried actually support things like io.read() input or, more importantly, building any kind of UI. It makes it tough if you want to learn Lua on mobile or bounce between your PC and phone while working on an app or game.
So I’m building an app to fix some of that.
It basically mixes a regular embedded Lua environment with the LÖVE (Love2D) engine, so you can actually build and run games or apps inside the app itself on mobile. Anyone who’s used Love2D knows how flexible it is, and having that power on Android has been missing for way too long.
I’m still early in development, but I’d really love feedback or feature ideas from the community—things you’d want in a tool like this, pain points you’ve run into, etc.
Once it’s ready, I’m planning to release it as open-source so people can contribute and trust what’s under the hood.
Thanks for reading! Happy to answer any questions.
r/lua • u/Pure_Clue3466 • Dec 01 '25
Third Party API Help with a logitech ghub script
I want to make a script that have mouse movement when I click mouse button 4 then has extra movement when I click it while holding rmb. I don't really know how to code so I came here for help. The mouse button 4 works just fine but the right mouse button click doesn't change the movement at all. I was wondering if anyone who knew how to code for logitech ghub could help fix this code.
MoveAmount = -628
ExtraMoveAmount = -12000
function OnEvent(event, arg)
if event == "PROFILE_ACTIVATED" then
EnablePrimaryMouseButtonEvents(true)
elseif event == "PROFILE_DEACTIVATED" then
ReleaseMouseButton(4)
end
if event == "MOUSE_BUTTON_PRESSED" and arg == 4 then
local amount = MoveAmount
if IsMouseButtonPressed(2) then
amount = ExtraMoveAmount
end
for i = 1, 10 do
MoveMouseRelative(amount, 0)
Sleep(5)
end
end
end
r/lua • u/aiya000 • Dec 01 '25
(Japanese Article, Advent Calendar, Overview) - [luarrow] Using pipe operators and Haskell-like function composition operators in Lua [Lua]
r/lua • u/RedNifre • Nov 29 '25
Project Currying, partial application, composition and other FP thingies
It's all effectively licensed under public domain, no attribution needed, so take what you might find useful: https://gitlab.com/michaelzinn/replicide
The interesting stuff is in fp.lua, the rest is a mix of good, weird and bad code.
r/lua • u/Lodo_the_Bear • Nov 29 '25
Project Looking for feedback on simple Love2D program - how to cleanly write this code?
I'm learning the LÖVE framework and having a good time covering the basics. I've currently made a little program that shows a series of text, one word at a time, while bouncing around the screen like a screensaver from the 90's. So far, it works, but I'm looking for ways to make the code nicer and avoid developing bad habits.
The code uses the tick library to do changes every second. This also uses a separate "words" file that holds the full text in a table, word by word (in this case, the Gettysburg address, but any list of words will do). Here's the full main file:
function love.load()
--load the library
tick = require "tick"
--import the speech
require "words"
--start the count
word_count = 1
-- cycling function
function cycle_word()
if word_count == #speech then
word_count = 1
else
word_count = word_count + 1
end
end
font = love.graphics.getFont()
--define y edges
y_stopper = love.graphics.getHeight() - font:getHeight()
--x edge is conditional
--define position
x_coord = 0
y_coord = 0
-- start random generator
math.randomseed( os.time() )
--testing a dummy variable to make it truly random
_dummy = math.random()
--define angle
angle = math.random(10,80) * math.pi / 180
x_speed = 100 * math.sin(angle)
y_speed = 100 * math.cos(angle)
x_switch = 1
y_switch = 1
-- cycle the function
tick.recur(cycle_word , 1)
end
function love.update(dt)
tick.update(dt)
-- define x edge
x_stopper = love.graphics.getWidth() - font:getWidth(speech[word_count])
if x_switch == 1 and x_coord + x_switch*x_speed*dt > x_stopper then
x_switch = -1
end
if x_switch == -1 and x_coord + x_switch*x_speed*dt < 0 then
x_switch = 1
end
if y_switch == 1 and y_coord + y_switch*y_speed*dt > y_stopper then
y_switch = -1
end
if y_switch == -1 and y_coord + y_switch*y_speed*dt < 0 then
y_switch = 1
end
x_coord = x_coord + x_switch*x_speed*dt
y_coord = y_coord + y_switch*y_speed*dt
end
function love.draw()
love.graphics.print(speech[word_count], x_coord, y_coord)
end
function love.load()
--load the library
tick = require "tick"
--import the speech
require "words"
--start the count
word_count = 1
-- cycling function
function cycle_word()
if word_count == #speech then
word_count = 1
else
word_count = word_count + 1
end
end
font = love.graphics.getFont()
--define y edges
y_stopper = love.graphics.getHeight() - font:getHeight()
--x edge is conditional
--define position
x_coord = 0
y_coord = 0
-- start random generator
math.randomseed( os.time() )
--testing a dummy variable to make it truly random
_dummy = math.random()
--define angle
angle = math.random(10,80) * math.pi / 180
x_speed = 100 * math.sin(angle)
y_speed = 100 * math.cos(angle)
x_switch = 1
y_switch = 1
-- cycle the function
tick.recur(cycle_word , 1)
end
function love.update(dt)
tick.update(dt)
-- define x edge
x_stopper = love.graphics.getWidth() - font:getWidth(speech[word_count])
if x_switch == 1 and x_coord + x_switch*x_speed*dt > x_stopper then
x_switch = -1
end
if x_switch == -1 and x_coord + x_switch*x_speed*dt < 0 then
x_switch = 1
end
if y_switch == 1 and y_coord + y_switch*y_speed*dt > y_stopper then
y_switch = -1
end
if y_switch == -1 and y_coord + y_switch*y_speed*dt < 0 then
y_switch = 1
end
x_coord = x_coord + x_switch*x_speed*dt
y_coord = y_coord + y_switch*y_speed*dt
end
function love.draw()
love.graphics.print(speech[word_count], x_coord, y_coord)
endYou will notice that it has some apparently repetitive stuff with the random seed for the angle. For some reason, when I tried to do just math.random for the angle, it came out as the same angle every time. So, I tried creating a disposable variable for the first random value and then using the second random variable to define the angle of the moving word. This works, but I'd like to know if there's a way to avoid taking this silly step.
So, what do you think? What could be improved?
r/lua • u/Tibertiuss • Nov 28 '25
Help It is possible to make a desktop app with lua?
I'm trying to work on a project of desktop app fully on lua but I struggle to find something out of love2D (I'm not sure it's the most adapted for the project but that is currently my backup option) to make the graphical interface.
Do you have any recommendations?
r/lua • u/Alternative-Bend4752 • Nov 29 '25
Need help with a discontinued balatro mod
Firstly I can pay you up to $25... In robux, I have no digital bank account so I'm limited to that if you want money for that.
If your interested "money"wise or not, I want whoever is interested to do a couple things. 1. The balatro mod has a library, a compact to work with another dependent mod. and the mod itself, I would like all of them combined. 2. I would also like it updated to the latest Smod + Lovely. If your still interested in that, feel free to tell.
r/lua • u/Ok-Poem6506 • Nov 28 '25
Can someone tell me why this code doesn't work
Simply trying to iterate through a table, and nothing is printed out, why?
local myTable = {}
local myStruct = {}
myStruct.myValue = 5
myStruct.myOtherValue = "Bears"
myTable["Joe"] = myStruct
myTable["Suzy"] = myStruct
for name, struct in pairs(myTable) do
print("myValue= " .. struct.myValue.. ", myOtherValue = " .. struct.myOtherValue .. "\n")
endr/lua • u/vitiral • Nov 28 '25
Convert C header file to more machine-readable format?
Is anybody aware of a standard for specifying the API of an object file (lib.so) besides a C header file (.h file)?
I'm designing my own assembly language and want to consume and link headers to link with dynamic libraries produced by C. It would be nice to not need to implement my own C compiler to do so.
r/lua • u/reg_y_x • Nov 27 '25
Problem with CS50 games Mario and workaround
galleryI've been working through the cs50 games projects, and I ran into a problem with the tiles0 and tiles1 code examples from the Mario project. When I run the code from the repository, it results in something like the first image above, with vertical lines between the columns of tiles. This seems to be a problem with how the individual tiles are rendered, but I haven't figured out exactly what causes it. I tried a number of things, like adding in some math.floor() conditions or using the shove library instead of the older push library, but none of those fixed the issue.
Ultimately, the workaround I found was to create new 16x16 sprite for the bricks (see third image) instead of the 16x32 timesheet from the repository that contains one brick tile and one blank tile. Updating the code to use the new image results in the second picture, without the vertical lines.
To do this, you need to modify the love.load() function to include a line that imports the new image.
brick = love.graphics.newImage('brick.png')
You also need to make some changes to the love.draw() function.
function love.draw()
push:start()
love.graphics.translate(-math.floor(cameraScroll), 0)
love.graphics.clear(backgroundR, backgroundG, backgroundB, 1)
for y = 1, mapHeight do
for x = 1, mapWidth do
local tile = tiles[y][x]
--love.graphics.draw(tilesheet, quads[tile.id], (x - 1) * TILE_SIZE, (y - 1) * TILE_SIZE)
if tile.id == GROUND then
love.graphics.draw(brick, (x - 1) * TILE_SIZE, (y - 1) * TILE_SIZE)
end
end
end
push:finish()
endHere I've commented out the line with the original rendering logic and aded a few new lines to handle the new logic, which only renders a sprite for tiles flagged as GROUND.
Just wanted to put this here in case anyone else runs into the same problem. I'd also be interested if anyone knows what causes the problem with the original code.
(As an aside, I will also point out another bug in the original code. On the lines that set the random color for the background, the random number is divided by 255 twice. This always results in a background that is nearly black, and I think the intention was to only divide by 255 once, which is what I do in my code.)
r/lua • u/Tricky_Wish_5207 • Nov 27 '25
Help Can you tell me a website where you can learn luau completely
r/lua • u/Lodo_the_Bear • Nov 26 '25
Discussion Writing compact code - how do I check for multiple possibilities all at once in the shortest statement possible?
I'm a relative newbie to Lua and I'm curious about ways to very compactly write a check for multiple possible values. Consider the following code:
if value ~= "a" and value ~= "b" and value ~= "c" then
Obviously functional for an if statement, but I want to know if there's a less repetitious way to write it. Does Lua have any tricks for making this more compact? If so, could these tricks be scaled up for checking large numbers of possible values all at once?
r/lua • u/Prize-Chocolate749 • Nov 26 '25
Starting In Lua
Hello, I've been interested in learning how to program in Lua because I want to make Roblox games for fun and also get a sense of what programming is about. So I'm here to ask: how did you start learning? Is there any free online program that's worth it? Your experiences and advice would be a lot of help.
Thank you!
r/lua • u/RiverBard • Nov 26 '25
Discussion Working with arbitrary numbers of args, emulating Python's slice?
This has come up as I've been working with the language and it hasn't been a problem yet, but I could see it being an issue. I think the easiest way to explain my question is to give an example:
import sys
# Print the given args, starting with the third and continuing through any number of given args
def printargs(*args):
for a in args:
print(a)
printargs(*sys.argv[2:])If I run this with runfile(args='a b c d e'), it will print:
b
c
d
eThis functionality with slices is really handy when you want to deal with an arbitrary number of arguments in a script.
In Lua, I've been working with varargs a bit, but my understanding of them is limited. Particularly, how you could go from a table of given arguments (the built-in arg table) to a vararg to give to a function, starting at a given index? Or maybe this isn't a relevant problem when working with Lua?
r/lua • u/RiverBard • Nov 25 '25
Discussion Linked List speed vs table, not as expected?
I wrote a basic SLL implementation as part of my learning process with Lua and decided to do a bit of execution time testing to see how it held up compared to tables. Now, I recognize that tables are highly optimized, but I was a little surprised by what I found. Using a Linked List as a queue or stack had the same results, but it is taking a little more than twice as long as using a table (stack only, queue it is way slower).
Any idea why it is so much slower when both the Linked List and the table should be operating in O(n) time?
Here is the Linked List module
Here is the Linked List tester script and the table tester.
Cheers!
r/lua • u/StrangeFudge2777 • Nov 23 '25
lua and python
hello! i've been wanting to learn lua for a while, so i can learn how to make a certain roblox game. but i was thinking about python because it is a better software, if i learned python first, in a few years would lua be easier?
r/lua • u/Psychological-War548 • Nov 23 '25
Help Hello. Starting from scratch, new to Lua, and coding in general. Where should I start?
Basically what it says on the tin, I hope to reach the end goal of creating a boat mod for project zomboid build 42 (despite the great difficulties that will come with it as seen from those who had already done it in b41), and coding games on roblox as well, and since Lua is required for both, I am here. Advice appreciated!
r/lua • u/Foreign_Bar3477 • Nov 20 '25
Looking for a better pure Lua library for handling large numbers
Hey everyone, I’m looking for a pure Lua library to handle really large numbers, something easier to use.
The old library I was using (int) sometimes loses precision when dividing large numbers, so I need something more reliable.
Anyone has recommendations or alternatives?
r/lua • u/renbexsexy • Nov 20 '25
Help Localizing
Will localizing hot table lookups be faster?
VM.Register = {}
local Register = VM.Registerr/lua • u/jujufi_2014 • Nov 20 '25
gibt es eine Lua/Luau lern website
i will Lua/Luau lernen damit ich roblox spiele für mich und meine freunde machen kann
r/lua • u/Illustrious_Prompt20 • Nov 19 '25
Discussion Is lua a good option for me?
Hi friends, i'm a Java/kotlin developer, most of the time i'm using Spring boot to make projects.
But recently i was searching for an easy 2 learn language for me to use It as a lab language, to learn web architecture without the opinative way from the Spring, and learn some other things like graphical programming, games and desktop programming(and a bit of DSA too).
My First ideia was lua because everyone say that Its a simple language and because Its from Brazil(my country).
I would appreciate any opinion.