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

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

Powered by : @r_channels & @reddit2telegram
Download Telegram
preprocessor in lua

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 heavywork(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 dosomethingawesome()
print("Registered at compile time")
end

-- (5) Retry on error (e.g., network calls)
\@retry(3)
function fetchdata(url)
return http.get(url) -- might error
end
-- fetch
data retries up to 3 times before finally erroring.

-- (6) Initialization hook
\@init
function setupenvironment()
print("Environment initialized!")
end
-- runs once, when the noscript is loaded.

-- (7) Documentation and metadata
\@doc("Calculates the nth Fibonacci number efficiently.")
\
@todo("Add tail‑recursive version")
\@tag("math", "performance")
\
@deprecated("Use fibfast 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!

https://redd.it/1kma10y
@r_lua
Confused about this noscript

So I found this noscript in this subreddit but it doesn't really work for this 3D model I have. I tested it with a normal part and it works. So my question is are parts and 3D models the same or do I have to do something else for this to work.

Heres the noscript: https://devforum.roblox.com/t/how-would-i-go-about-part-always-facing-player/1182594/2

When I put the noscript for my 3D model it doesn't work but it does if its a part.

https://redd.it/1kmysv0
@r_lua
New to Lua! Need code review to my fzf in lua

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

https://redd.it/1knelrd
@r_lua
I never coded. I’m trying to learn lua throguh immersion on Reddit.

im Making a game. Where You click a button, that button gives you a coin, that coin can be transferred as bitcoin. Give me lua codes!

https://redd.it/1knvut4
@r_lua
Route No.7 of RSWO Order
https://redd.it/1knw01c
@r_lua
Looking for Developers to Build a Powerful FiveM Anti-Cheat Team

Hey everyone,
I’m currently working on building a new, advanced FiveM Anti-Cheat system that will compete with top names. The goal is to create a complete system with:
• Powerful client-side and server-side detection
• Trigger & event logging
• Cheat bypass detection
• Ban system with SQL logging & Discord webhook logs
• Clean and modern GUI
• Optimized performance and obfuscation
• Full config system and export-ready files

I’m looking for experienced people in the following areas:
• Lua development (FiveM client/server)
• C++ (for DLLs or native-based detection)
• SQL & Discord integration
• UI design for NUI menus
• Testing & exploit research

This project is serious and will be released with a licensing system. I’m open to profit-sharing if you’re dedicated and want to build something long-term.

If you’re interested, feel free to DM me or contact me on Discord
Discord: wayzedev

Let’s build the most secure anti-cheat together!

https://redd.it/1ko9f6n
@r_lua
Need to find a LUA dev

Hi! I need to find a lua dev to make a fast and really simple noscript if anyone can do it for free!

Discord: hassantaxi

https://redd.it/1ko92x7
@r_lua
project setup with busted

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 noscripts, but a more integrated approach would be preferred.

https://redd.it/1koq15g
@r_lua
Lua for Pokemon Pinball

Would anyone know know how to write a Lua noscript to the makes the entire playfield visible in pokemon pinball RS?

https://redd.it/1kot5zn
@r_lua
CRC32 implementation help

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 luacrc32(luaState L) {
uLong crc = crc32(0L, Z_NULL, 0);
const char
str = luaLcheckstring(L, 1);
uInt len = strlen(str);
crc = crc32(crc, (const Bytef *)str, len);
lua
pushinteger(L, crc);
return 1;
}

https://redd.it/1kowq1s
@r_lua
Lua for gamedev and type system

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?

https://redd.it/1kozn33
@r_lua
Lua linux executable

Hi! I’ve been having trouble creating a portable executable that doesn’t require installation. Here’s my project and the AppDir folder.

Hasheito

├── conf.lua

├── Hasheito.love

├── icon.png

├── Logica.lua

├── lua_modules

│   ├── lua_modules.lua

│   └── sha2.lua

├── main.lua

└── suit

├── button.lua

├── checkbox.lua

├── core.lua

├── docs

│   ├── conf.py

│   ├── core.rst

│   ├── gettingstarted.rst

│   ├── index.rst

│   ├── layout.rst

│   ├── license.rst

│   ├── Makefile

│   ├── _static

│   │   ├── demo.gif

│   │   ├── different-ids.gif

│   │   ├── hello-world.gif

│   │   ├── keyboard.gif

│   │   ├── layout.gif

│   │   ├── mutable-state.gif

│   │   ├── options.gif

│   │   └── same-ids.gif

│   ├── themes.rst

│   └── widgets.rst

├── imagebutton.lua

├── init.lua

├── input.lua

├── label.lua

├── layout.lua

├── license.txt

├── README.md

├── slider.lua

├── suit-0.1-1.rockspec

└── theme.lua

Hasheito.AppDir/

├── AppRun

├── Hasheito.desktop

├── hasheito.png

└── usr

├── AppRun

├── bin

│   └── Hasheito

├── lib

│   ├── lfs.so

│   ├── libbrotlicommon.so.1

│   ├── libbrotlidec.so.1

│   ├── libfreetype.so.6

│   ├── liblove-11.5.so

│   ├── libluajit-5.1.so.2

│   ├── libmodplug.so.1

│   ├── libmpg123.so.0

│   ├── libogg.so.0

│   ├── libopenal.so.1

│   ├── libpng16.so.16

│   ├── libSDL2-2.0.so.0

│   ├── libtheoradec.so.1

│   ├── libvorbisfile.so.3

│   ├── libvorbis.so.0

│   └── libz.so.1

├── license.txt

├── love.desktop

├── love.noscript

└── share

└── lua

└── 5.1

├── lua_modules

│   ├── lua_modules.lua

│   └── sha2.lua

└── suit

├── button.lua

├── checkbox.lua

├── core.lua

├── docs

│   ├── conf.py

│   ├── core.rst

│   ├── gettingstarted.rst

│   ├── index.rst

│   ├── layout.rst

│   ├── license.rst

│   ├── Makefile

│   ├── _static

│   │   ├── demo.gif

│   │   ├── different-ids.gif

│   │   ├── hello-world.gif

│   │   ├── keyboard.gif

│   │   ├── layout.gif

│   │   ├── mutable-state.gif

│   │   ├── options.gif

│   │   └── same-ids.gif

│   ├── themes.rst

│   └── widgets.rst

├── imagebutton.lua

├── init.lua

├── input.lua

├── label.lua

├── layout.lua

├── license.txt

├── README.md

├── slider.lua

├── suit-0.1-1.rockspec

└── theme.lua

The last error was:

Error

//Logica.lua:3: module 'sha2' not found:

no field package.preload['sha2'\]

no 'sha2' in LOVE game directories.

no file 'sha2' in LOVE paths.

no file './sha2.lua'

no file '/usr/share/luajit-2.1/sha2.lua'

no file '/usr/local/share/lua/5.1/sha2.lua'

no file '/usr/local/share/lua/5.1/sha2/init.lua'

no file '/usr/share/lua/5.1/sha2.lua'

no file '/usr/share/lua/5.1/sha2/init.lua'

no file './lua_modules/sha2.lua'

no file './sha2.so'

no file '/usr/local/lib/lua/5.1/sha2.so'

no file '/usr/lib/lua/5.1/sha2.so'

no file '/usr/local/lib/lua/5.1/loadall.so'

Traceback



[love "callbacks.lua"\]:228: in function 'handler'

[C\]: in function 'require'

//Logica.lua:3: in main chunk

[C\]: in function 'require'

main.lua:3: in main chunk

[C\]: in function 'require'

[C\]: in function 'xpcall'

[C\]: in function 'xpcall'


I hope you can help me guys!

https://redd.it/1kp1f64
@r_lua
Animations broken and I can't figure out why
https://redd.it/1kp4mrh
@r_lua
Can lua be used to distribute malware?

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.

https://redd.it/1kq8a7h
@r_lua
Is there any 3D Game Engines that uses lua?

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

https://redd.it/1kqjc2s
@r_lua
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 ?

https://redd.it/1kr4egc
@r_lua
Help with creating simple "Fantasy Console" with basic stuff

Dead Everyone,


I am using LuaRT and I want to make a Fantasy Console. It looks really cool and I want to make my own version of it! Pls help I am a beginner! TIC-80 LOOKS FANTASTIC as it is retro-themed and is rainbow!

https://redd.it/1krf08o
@r_lua
Erro em um código

Comecei a menos de uma semana a programar em lua, estou seguindo uma lista de exercícios e estou com um problema nele. Sempre que coloco um numero para ele somar, dá erro falando que o valor é nulo. Alguém consegue me ajudar?


CODIGO:

--[
Faça um Programa que peça dois números e imprima a soma.
--]
print("Digite um numero")
local
numb1 = tonumber(io.read())
print("Digite outro número")
local
numb2 = tonumber(io.read())

if
(numb1 == nil or numb2 == nil)
then
   
while
numb1 == nil or numb2 == nil
do
        print("Por Favor, digite um numero valido")
        print("Digite um numero")
        numb1 = tonumber(io.read())
        print("Digite outro número")
        numb2 = tonumber(io.read())
   
end
   
local
soma = numb1 + numb2
    print("A soma desses dois valores é " .. tostring(soma))
else
   
local
soma = numb1 + numb2
    print("A soma entre esses dois é de " .. tostring(soma))
end


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