Lua - Reddit – Telegram
Lua - Reddit
30 subscribers
280 photos
31 videos
4.24K links
News and discussion for the Lua programming language.

Subreddit: https://www.reddit.com/r/lua

Powered by : @r_channels & @reddit2telegram
Download Telegram
Yet Another Lua5.1 UTF8 library

I was writing a parser and found all the UTF8 support libraries for Lua are not up to my very high standards /hj. Sooo... I made my own. https://gitlab.com/cinntoast/lutf8

It's on the larger side after compilation because it includes the whole utf8proc database inside of it, but that's a trade off. For now it's just for iterating and identifying unicode codepoints, but I plan to add the utf8 regex capabilities in the few coming days.

Features (and plans):
\- Identifying properties of codepoints (implemented)
\- Validating utf8 sequences (implemented)
\- Mapping/Casefolding/Decomposing/etc sequences (implemented)
\- Bitwise options for lua5.3+ (implemented)
\- Meta file included for people using sumneko language server (wip)
\- POSIX Regex Patterns (planned)

Note: It's still largely untested, and a WIP

https://redd.it/1ldy89z
@r_lua
Personal standard - top level expression is =<exp>

How bad of it is me to just use \
= as my universal top level expression trick. No one's going to be using _ as variable.

I come from C. We do this hacky shit 24/7. But I wonder how it is by lua standards lol.

https://redd.it/1ldyx8k
@r_lua
how to use lua-compat-5.3 in C ?

Hello,

What is the proper way to use lua-compat-5.3 from C ?

I did a

luarocks install compat53

but it seems it only installed Lua part (some .so in luarocks' tree), but no compat-5.3.h anywhere ?

thanks

https://redd.it/1ldywz9
@r_lua
I'm writing a custom lua interpreter with modified semantics, I need your feedback

I'm currently making a custom lua interpreter, with a few behavioural changes to the language, and would like to get some feedback before I release the interpreter.

The main differences are with how "nil"-s are handled:

* Setting a field to "nil" doesn't delete it. It simply holds the value of "nil"
* Consequently, an array may contain a "nil" value
* Getting a field that doesn't exist throws an error, instead of returning "nil"
* Coroutines are symmetric, but that doesn't matter much, since there will be assymetric coroutines, using the built-in symmetric ones

Of course, treating "nil" as any other value means that we need a "del" function to delete fields of tables, and since getting a field that doesn't exist is an error, we need a "has" function that checks if a table contains a field.

It goes without saying that this will break quite a lot of existing lua code, but my main argument is that each minor release of lua so far has included a lot of breaking changes.

Aditionally, the built-in compiler will have some extended syntax, but the compiler is completely interchangeable, so a basic lua compiler without all the bells and whistles can be used instead.

Still, the syntax features I have implemented (and plan to implement) so far are the following:

**Procedure literals:**

same as function literals, but are declared as `begin statements... end`, and may be used in a parenthesis-less calls - `my_func begin end`

**While-local and if-local:**

allows the condition of a while or an if to be a declaration. The value of the first declared variable will be used as the condition, the rest will be accessible in the body of the statement

local function split_file(path)
if local basename, ext = path:match "^([^%.]+)%.(.-)$" then
return basename, ext;
else
return path, nil;
end
end

**Methods in table literals:**

Self explanatory imho

local obj = {
a = 1,
b = 2,
function test(self) return self.a + self.b end,
}
print(obj:add());

**Template literals:**

Haven't gotten around to it, but something like JS's template literals:

local world = "Josh";
local str = `Hello, ${world}`;
-- Or alternatively
local str = $"Hello, ${world}";
local str2 = $'Hello, ${world}';
local str3 = $[[
This is quite a long string.
Hello, ${world}
]];

Do the syntactical features look ok, and more importantly, are the behavioral changes I have made worth it or should I keep the original lua specifications (or maybe enable my semantics with a special comment, like `--# use strict`?)

I'm open to critique and ideas.

(Also, don't get the impresssion the compiler requires semicolons, I just prefer writting them...)

https://redd.it/1le9x04
@r_lua
Bitwise operators in LuaJIT

I'm making a Lua interpreter using LuaJIT (for performance), and would like to know if there's any way to implement bitwise operators to LuaJIT. They're in Lua >=5.3 and would like to know if anybody would make a patch for LuaJIT that implemented these. I know about the bit library but I don't really like it. I want true bitwise operators. I also want compound operators and the continue statement, and I found this: https://github.com/SnapperTT/lua-luajit-compound-operators

https://redd.it/1lekabq
@r_lua
how can i learn luau?

well i want to learn luau to make a roblox game. does anyone know a website that is really good for learning luau?

https://redd.it/1lf89xx
@r_lua
Learning Lua from an older version

I'm totally new to Lua or any programming language. I'm trying to learn this language from a YouTube course. Is it ok to learn Lua if the tutor of the course is using an older version and I'm using a more recent one?

https://redd.it/1lffqkb
@r_lua
Can someone help me?

Can someone take the time to help me obfuscate this noscript?

There is the link: https://pastefy.app/MgYbfktM/raw

Thank you if you help me 🙏.

https://redd.it/1lfhj9r
@r_lua
Can someone help me learn lua?

I'm new to coding and have more or less no idea how to noscript. If anyone could help me it would be greatly appreciated

https://redd.it/1lgpqmv
@r_lua
Can someone please help me if they know how the heck I can find this issue with my code for a mod im making for balatro? (the most coding experience i have is Scratch so bear with me lol) Code is below
https://redd.it/1lhlfwy
@r_lua
RN07 Maze-plan-(abandoned)

12:31pm 25/4/25 Just watched 'They cloned Tyrone'. Well I think I want the floor to be a bunch of mazes, like, going down, like an inverted climb, but a different shape of hallway collections each floore, I think that would be a nice way to challenge myself, after all, it wouldn't be too stressful a mission to complete a level each play, would it? It only has to be walls too, not neccessarily ceilinged, and any new ideas can fall to the next level, and then each floor has an entrance and exit, but also it fills the gap, to an extent, doesn't it? So it'll look nice from the outside, and on the inside it's a classic, but it remains then to accept the cliche and grind it from the first, and maybe a few good designs can trickle back up. I got the idea from this carpet pattern the protagonist is dragged by after he's shot in the film I just watched, it's a tesselation of octagonal spaces linked to neighbours, and disjoint encirling ones, bright yellow on black, and it's easy enough, because lets' face it, this multi-level shopping mall stuff is way out of my reach if I'm doing all this philosophizing. I should even do up a plan beforehand, with the floorspace included. But that's next week, or something, because I have had enough of it this week, after spilling my guts and making a show of it to D____. Besides, just a floor each session, that's reasonable, that's the way these things are meant to be played aren't they, I mean, when you clearly aren't Mr. Goodhope saving the damsel and saving the world. Even just a few starter levels would be right, a right job. Sheesh, I am f***ing exhausted.


On the other hand, I've also just downloaded some 'Alien' game and want to check it out and see if it works. Man I'm so goshdarn decadent. I don't know what's more evil, the building or the playing. I mean, what in tarnation are we gonna make that is actually a genuinely good thing, because I can't get away from the meat either when I'm deep in the work, and I don't want to be all taking these offerings against my style of personality development, my social enquiries, my open book ethical standard of discourse, wow there are so many good things I have to say about myself. But then again, the question is what makes you a good person, because it's like, you can do a good thing, or you can have a good thing, but something I haven't tried is this Alien game and to be honest, it's probably the best experience, but am I going to be able to play it the way I want or am I just going to be yo-yo-ing between that and the build and then just decide that it's all meaningless? How do I know the aliens are bad? How do I know I'm going to be sprinting around with loads of cavalry all day with some rad skins in space? But I mean, I don't do skins, do I? I buy skins, but I don't make them. I don't have a skin system, I mean, and I never did, but someone is having to smooth it all out for everyone else, and maybe I know enough about the stones anyway to be able to look at literally anything else, but then obviously there are a few questions I should ask, perhaps in the build I do, like do I really think that it's 'all skins'? Could the universe be 'just skins'? I mean that's like saying it's 'all atoms'. but, yeah, it is, but there's patterns of nature too. It's just, in nature there are levels of patterns all the way down to the atoms, but in games it's no longer a physical level, and the naive approach is punished with existential angst. You think you are a master of alchemy and substance but you still have to beg for the g****, because you ... you can't even wrap up a level, never mind a skin of a cloak and dagger celebrity. But if you want to go down the road of skin acknowledgement there's a rich tapestry of delusion that might make your world for you, all you have to do is be honest and subscribe to that 'theory of skins' and write your damn thesis in the world and see how much discord it causes amongst the locals who have lived in those places for a long time. Like, does anyone really want to get into arguments about
it with you, I mean you're so softly spoken. Go back to your stones.

Edit(23.6.25) It was just a layer of rush. Then RN06 was to produce chardust, and paths through chunks. RN05 will be making it pass for the ages, with some closure.

If anyone would like to help, answer this:
It would be ideal if sketches made with the chalk, or some future chalk, on a block could stay with it when dug to the inventory for later re-placement. So you could just sketch whatever textures you want, and leave them somewhere for later placement as though they were already part of the registered node list.

I also have to include
in chalk/canvas.lua[Ln156-173]: instruction to not apply this draw function when bitmap position is within half the duster's patch width from a surface's edge. It has to check the location of the crosshair for being less than scrubbing distance for the boundary etches, and end the function, so that item does not initiate error sequence. Otherwise I have to bear in mind the repercussions while using the duster in [RSWO][a]
[a]:https://github.com/flowingpoint/RSWO

https://redd.it/1liox5e
@r_lua
Here we go!!! I hope i don't quit like everything i tried in my life. (Any Advice is welcome. I want to finish something)
https://redd.it/1ljtsgh
@r_lua
Didn’t expect to use Lua for embedded dev,now I’m using it on microcontrollers

I always thought Lua was just for game noscripting or tweaking config files, didn’t even know people were using it to control hardware. Recently tried it out on an esp32 (was just playing around with IoT stuff) and was surprised how smooth it felt. I wrote Lua code in the browser, pushed it straight to the device, and got a working UI with MQTT + TLS in way less time than it would’ve taken me in c.

Didn’t need any local installs, toolchains, or compiling, just write + run.

Kinda wild that something this lightweight is doing so much. Curious if anyone else here using Lua in embedded or low-resource environments? Would love to see what tools/setups you’re using.

https://redd.it/1ljynal
@r_lua
I want to learn lua as my first language

If you could give me tips and like ways to do it in a hands on way that would be nice

https://redd.it/1lkjhkq
@r_lua
No recoil superlight 2

# Can someone help me in creating a "No Recoil" Script for Logitech superlight 2?

https://redd.it/1ll4r82
@r_lua
Lua Test and Automation Framework (TAF)

I am an Embedded Firmware Engineer and a few months ago my friend showed me a Robot Framework his company uses for writing end-to-end tests for the embedded devices.
I was speechless. Let's just say that I did not like it :)

So I decided to write a single tool that could:

run fast unit-style tests and longer integration tests,
talk to embedded boards over serial and drive browsers with WebDriver,
print pretty TUI dashboards in the terminal without heavyweight IDEs,
let me noscript everything in a high-level language but still drop to C when I need raw speed or OS access.

so I kindly present TAF (Test-Automation Framework).

---

### Feature list

| Feature | TL;DR |
|---------|-------|
| Lua 5.4 test files | Dead-simple taf.test("name", function() … end) syntax; hot reload; no DSL to learn. |
| C core | The harness itself is a ~7 K LOC C binary → instant startup, tiny footprint. |
| Serial module | Enumerate ports, open/close, read_until() helper with timeouts/patterns – perfect for embedded bring-up logs. |
| Web module | Thin WebDriver wrapper (POST/GET/DELETE/PUT) → drive Chrome/Firefox/Safari from the same Lua tests. |
| Process module | Spawn external procs (taf.proc.spawn()), capture stdin/stdout/stderr, kill & wait – good for CLI apps. |
| TUI dashboard | ncurses fallback (or Notcurses if available) – live view of “current test, current file:line, last log entry, pass/fail counter”. |
| Defer hooks | taf.defer(fn, …) to guarantee cleanup even if an assert() explodes. |
| Pluggable logs | Structured JSON log file + pretty colourised console output -> pipe into Grafana or just cat. |

---

### Quick taste (Serial)

local taf = require("taf")
local serial = taf.serial

taf.test("Communicate with GPS Device", {"hardware", "gps"}, function()
-- Find a specific device by its USB product string
local devices = serial.list_devices()
local gps_path
for _, dev in ipairs(devices) do
if dev.product and dev.product:find("GPS") then
gps_path = dev.path
break
end
end

if not gps_path then
taf.log_critical("GPS device not found!")
end

taf.log_info("Found GPS device at:", gps_path)
local port = serial.get_port(gps_path)

-- Ensure the port is closed at the end of the test
taf.defer(function()
port:close()
taf.print("GPS port closed.")
end)

-- Open and configure the port
port:open("rw")
port:set_baudrate(9600)
port:set_bits(8)
port:set_parity("none")
port:set_stopbits(1)

taf.print("Port configured. Waiting for NMEA sentence...")

-- Read until we get a GPGGA sentence, with a 5-second timeout
local sentence = port:read_until("$GPGGA", 5000)

if sentence:find("$GPGGA") then
taf.log_info("Received GPGGA sentence:", sentence)
else
taf.log_error("Did not receive a GPGGA sentence in time.")
end
end)


---

### Where it stands

Works on macOS and Linux (Windows native support is in progress, WSL should just work).
Docs live in the repo (docs/ + annotated examples).
Apache 2.0 licence.

---

### Road-map / looking for feedback

Parallel test execution (isolated Lua states + fork() / threads).
Docker/Podman helper to spin up containers as ephemeral environments.
Better WebDriver convenience layer: CSS/XPath shorthands, wait-until helpers, drag-and-drop, screenshots diffing.
Pre-built binaries via GitHub Actions so you can `curl | sh` it in CI.
TAF self test (Test TAF with TAF)

If any of this sounds useful, grab it: <https://github.com/jayadamsmorgan/taf> (name collision with aviation “TAF” accepted 😅). Star, issue, PR, critique – all welcome!

Cheers!


https://redd.it/1ll9u3u
@r_lua