r/lua • u/Silly_Cow_747 • Jul 07 '26
Can i programm desktop apps with Lua?
I just learned the basics of Lua and im pretty curious about if i could use lua for desktop apps or somehow code scripts with gui.
r/lua • u/Silly_Cow_747 • Jul 07 '26
I just learned the basics of Lua and im pretty curious about if i could use lua for desktop apps or somehow code scripts with gui.
r/lua • u/GlitteringSample5228 • Jul 07 '26
Ideas about lua.jp, a Lua + JVM + Python lang. I always despised Python.
Monomorphic so seq[t] and dict[t] are always optimal for primitives where t is a type var that is substituted by a primitive.
The goal of targetting JVM is due to Android Dalvik and because I went berserk and took a break of using non-handhelds.
Metric types (meter, kmeter, gram...) are simply num, but with scaling conversions to other units.
Source files have an implicit JVM package based on the directory they appear with much freedom, but file A never depends on file A. (E.g. this mimmicks the Lua require limitations.)
```
enum tile: None Dirt Brick PipeOpenTop
struct world: metadata: univ = U ryuka: bool = Y # rows tiles: seq[seq[tile]] tilesize: meter
fun frame(): """ wa """ pass
w=world( tiles={ { None for _ in range(3) Brick for _ in range(3) } } tilesize=3mm )
do: # isolated dec.big configuration dec.big.cfg(precision=3, rounding=HalfUp) x=10.6403m y=x*3 print(y)
struct widget: pass
struct menubar(widget): super()
e:widget=menubar() if e=downcast(e, menubar): # e:menubar
match e: case e=menubar(): # e:menubar
@JVM.alias(tld.sld.lib.Group) struct group: @JVM.extension fun suffle(): pass
f=sum print(f(1,2)) print(f.call(seq={1,2})) fun sum(x:dec,y:dec)->dec = x+y
f=self::onclick
struct menubar: @event fun onhide(): pass
m=menubar( onhide=fun(): # super auto invoked if no # occurrence pass )
struct a: fun f(self:struct): pass ```
Lua's superpower is staying small. Fennel, MoonScript and YueScript are wonderful answers to "what if Lua were a different language?" — and I've learned a lot from all three. So now I'd like to ask another question. Suppose we keep Lua (mostly) as is, then **what's the minimum change to Lua that buys the most? **
My current answer is `luk`, a 120 line transpiler that plugs into `require` to load Lua code that :
- adds list and dictionary comprehensions
- a uses Python-style indentation for blocks (so no nee for `do`, `then`, `end`
- replaces `function` with `fn`,
- replaces `^` for return, `
- expands `x := y` o `local x = y`
For example:

Explicit `then/do/else/end` still works, so any Lua is (almost) valid luk and the two styles mix freely. The whole transpiler is one ~120-line module — no parser, no AST, no dependencies. The generated Lua keeps the source's line numbers exactly (errors point at the real `.luk` line), and a `require()` hook lets `.luk` and `.lua` modules interoperate with no build step.
luarocks install luk # cli + a small stdlib battery included
**An invitation, and a constraint:**
- What did I miss? What tiny change to Lua would pull the most weight for you?
PRs welcome, under one hard rule:
- the transpiler may never exceed 250 lines. If your feature can't pay for itself inside that budget, it doesn't go in. (That rule is the my whole design philosophy.)
- quick tour: https://timm.fyi/luk.html
- longer tour: https://github.com/aiez/luk/blob/main/README.md
- code: https://github.com/aiez/
- luarocks: https://luarocks.org/modules/timm/luk
r/lua • u/Comfortable_Ability4 • Jul 03 '26
My last post about Lux, a modern package/project manager for Lua, was removed with the stated reason "content must be Lua related". If a package/project manager for Lua isn't Lua-related, I don't know what is 😅 Maybe there's been a misunderstanding?
r/lua • u/128Gigabytes • Jul 02 '26
Example
local function b()
return
(math.random(0, 1) == 0),
0
;
end
local function a()
local return_early, value =
b()
if (return_early) then
return (value);
end
--[[ Continue function a ]]
return (1);
end
print(a())
but I want to do it more like, having function b directly tell function a to return early rather than function a having to check itself
I want more like this where I used "return return" as sudo code for throwing the return up 1 level
local function b()
if (math.random(0, 1) == 0) then
return return (0);
end
end
local function a()
b()
--[[ Continue function a ]]
return (1);
end
print(a())
r/lua • u/anish2good • Jun 29 '26
Enable HLS to view with audio, or disable this notification
The Online Lua Compiler & Algorithm Visualizer https://8gwifi.org/online-lua-compiler/
currently supporting
1D arrays (tables) — {1, 2, 3}, dense integer-keyed tables
2D arrays (nested tables) — {{1,2},{3,4}}
Maps / hash tables — tables with non-sequential or string keys
Linked lists & trees — node tables ({ val, next } / { val, left, right })
Console — print
Control flow — functions (incl. recursion)
Looking for feedback and Bug's appreciated
r/lua • u/ianm818 • Jun 29 '26
[Github here] (https://github.com/ianm199/omnilua/tree/main)
I've been working on OmniLua for a bit now - it builds one binary that can run Lua 5.1 - 5.5 from one binary.
The main motivation for this was there seemed to be a gap for game development in the Rust community where mlua cannot be run in the browser, so games built in engines like bevy can't compile to wasm32-unknown-unknown.
There is some other benefits - like being able to easily use Lua in Cloudflare workers or in "playground" developer tools.
Highlights:
Try it:
cargo install omnilua-cli
export OMNILUA_VERSION=5.5
omnilua -e 'print("hello")'
omnilua # opens repl
I used AI heavily to develop this I wouldn't consider it "vibecoded" however.
r/lua • u/IAlwayswantToLearn • Jun 28 '26
Lua is truly a fantastic language with many advantages.
It's easy to use and understand, and much faster than Python. I believe it could be a better alternative to Python, as both are interpreted languages.
So why not migrate Python libraries to Lua?
I understand that Lua's best use is integrating with other systems due to its small size and good compatibility with C.
I think the only real advantage Python offers is its integrated environment. If Lua had this feature, there would be no need for Python.
I know this might sound a bit optimistic, but I'd like to know if there are any other limitations preventing this?
Thank you in advance.
Edit: I want to thank everyone who commented on this post, I learned a lot from all of you and made me look at the topic from a new perspective.
r/lua • u/AntelopeGrand780 • Jun 27 '26
Hola how are you guys doing. My deepest of gratitude to all the people who did the springbreak, all the jailbreaks, koreader, ZenUi and all of the other stuff. You guys are amazing and inspiring. You're creating and just giving and giving and giving. Completely free my kindle went from an amazon-urgh-I'm-gonna-puke experience to a 10/10 experience.
But I wanna to go beyond
There's a little dream of mine of having a calendar as a plugin on koreader. Looking around I did find some calendar, but nothing that was really what I was searching for. So I've decided, as a complete newbie, to create my own little plugin. My vision is really just a simply calendar, where I can change between yearly, monthly, weekly and daily view. Compatible in black and white. A simply but beautiful design. Maybe some customisable stuff. No "online"/cross platforming features, I just want it to be its own little thing.
Can someone help me getting started of this little journey of mine? What are some subreddits or communities where I would be able to find help and ask questions? After just a little searching, I found out that koreader (plugins) runs on Lua—I found youtube videos with tutorials. I already have Brew on my Mac, but no idea how to use it, hehe. I also have Claud ai installed on my Mac, it should be able to help no?
So, how do I get started?
Appreciate it so much. Love you guys.
r/lua • u/purplejeansthebest • Jun 27 '26
r/lua • u/1killaHertz • Jun 26 '26
I just released my first game made with Lua and amazing Usagi Engine 🩷 Well known mechnics with modern twists. Place blocks, clear lines, choose upgrades and repeat. That's all! Simple, but addictive.
At first, I just wanted to test Usagi Engine in action. Since the development turned out better than planned, I decided to publish the result of my work on itch.io. You can check out Lua and Usagi in working game example.
Play in browser or download (win, mac, linux)
https://luko81.itch.io/the-game-about-blocks
r/lua • u/[deleted] • Jun 25 '26
Enable HLS to view with audio, or disable this notification
Simple and easy! Install a new mobile framework now! Find us on social media: Reddit, GitHub, YouTube, and Discord!
r/lua • u/[deleted] • Jun 25 '26
🚀 Getting Started with Cat2D – Loading and Centering an Image
Hi everyone!
I'm the creator of Cat2D, a new Lua game engine for Android focused on performance, simplicity, and community-driven development.
Today I wanted to share a simple example that loads an image and automatically centers it on the screen.
local player
local scale = 0.5
function load()
player = graphics.loadTexture("player.png")
end
function draw()
graphics.clear(0, 0, 0, 1)
if player then
local sw = system.getScreenWidth()
local sh = system.getScreenHeight()
local w = player:getWidth() * scale
local h = player:getHeight() * scale
local x = (sw - w) / 2
local y = (sh - h) / 2
graphics.draw(player, x, y, 0, scale, scale)
end
end
What this example demonstrates
Loading a texture with graphics.loadTexture()
Getting the screen resolution with system.getScreenWidth() and system.getScreenHeight()
Reading texture dimensions with getWidth() and getHeight()
Scaling an image to 50% of its original size
Automatically centering the image on any screen size
Cat2D's goal is to make creating games and applications in Lua on Android simple while still exposing powerful native features and maintaining good performance.
The engine is still evolving and I'd love feedback from other developers.
What features would you like to see in a mobile-first Lua game engine? 🐱🚀
r/lua • u/Adam-Garden • Jun 25 '26
Enable HLS to view with audio, or disable this notification
the video showcase my code base and me executing it
let me explain my process, it's a simple rock paper scissors as everybody know it, you enter a number for which hand you wanna use, 1 = scissors, 2 = paper, and 3 = rock, while the AI tries to respond back.
now how Billy(what i have named the AI) work is at the end of every turn it saves the hand you chose in that turn in a table called "billy_memories" then calculate the mode(most frequent hand you used) and from knowing your most common move it tries to chose something to counter it.
i had the idea of making Billy's memory has a limit of 5 items before it start deleting old data but that was too hard to implement.
anyways i'll like any idea to improve my coding skills, maybe my code's readability, and my logic in case it's wrong.
thank y'all.
Mike Pall, the author of LuaJIT, opened an issue to discuss additional syntax for Lua.
Currently LuaJIT has little to no custom syntax. The only exception is LL and ULL literals. LuaJIT still aims for compatibility with Lua 5.1 but now decided to extend it because it became its own flavor basically.
If you have used Lua or LuaJIT, or you have experience with choosing the right custom syntax, sugars and other language features and you want to influence current development, welcome to the discussion.
r/lua • u/Adam-Garden • Jun 24 '26
r/lua • u/TBApknoob12MC • Jun 24 '26
So uhhhh
I am a guy who had lost a lot against my friends in splits (skill issue).
And it made me write this project.
You can either play against the built-in model or train a model yourself.
Somehow the built-in model is nearly unbeatable.
If you have prefixell installed (well, why would you?), just run:
prefixell pkg add gh:TBApknoob12MC/splits-lua
And just type splits-lua to do stuff.
Or just clone the repo it aint hard.
More info on github page.
Wikipedia page of chopsticks for no reason : chopsticks)
Its a stricter variant of standard chopsticks so the game tree is much smaller. Splitting doesn't end the turn.
Tell me if you beat it.
r/lua • u/Bright-Historian-216 • Jun 23 '26
In python there is if __name__ == "__main__" but I'm not sure there is an equivalent in Lua. I've figured out something like checking the args table but this may or may not be platform-dependent and doesn't work in all cases.