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

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

Powered by : @r_channels & @reddit2telegram
Download Telegram
Sub chat

Am looking for some lua coders here ,I have a problem with a roblox code, it's subbost to comment commands I selected and it's not working ,I tryed with Claude and gpt and still not working ,the code suppost to work in the noscript emulater (if you know what I mean) and not on roblox studio itself, can anyone help ;( ?

https://redd.it/1iodxer
@r_lua
Arrays start at 1 executive order
https://redd.it/1iosmv3
@r_lua
Why you should know Lua

Okay, maybe you don’t have to, but it’s definitely useful. People who know me well might be surprised here. They’re aware that my first programming language was PHP, but they don’t know that my second wasn’t JavaScript, it was Lua. I bet even my friends are confused now, and you probably are too. We’ll circle back to this.

## Why Should I Care?

That’s a fair question, especially if you already know other noscripting languages. Sure, you can live without Lua. But it’s lurking in places you’d never expect.

It’s popular, even if you rarely hear about it. Not as hyped as those Python devs who import every single letter, or Java folks in suits at banks, but Lua has an active community and plenty of great resources.

## It’s Simple. Too simple

Lua is a minimalist language with clean, straightforward syntax. It avoids unnecessary complexity, so you can learn it in a couple of hours. And here’s the classic example:

print('Hello, everyone! Except Java folks.')

if you.crazy() then
learnJava()
end


Lua isn’t usually used solo. It’s often embedded in game engines, other software, or paired with C/C++. I could list endless examples of where it’s used, but check this out if you’re curious.

## It’s fast

Lua is one of the fastest interpreted languages. It compiles to bytecode and runs on a virtual machine, giving it a significant speed advantage over other noscripting languages. That’s why it’s used in game engines and paired with C/C++ it’s easy to integrate and lightweight. Lua itself is tiny.

## Gaming

Ever played World of Warcraft? Or maybe you still do? (RIP your social life.) If so, you’ve heard of addons like browser extensions, but for games. Those addons are written in Lua. Back in school, I wrote and tweaked them myself. Magical times. As you might have guessed, yes, I did this before diving into client side web technologies. Oddly, I already knew PHP by then. If anyone’s interested, I could write a separate post about that.

Lua isn’t limited to WoW, though. It’s in game engines like:

- Godot (Lua support via GDScript wrappers)
- Love2D (a Lua-first engine)
- Defold (Lua as the main language)
- Gideros (mobile game engine)
- Cocos2d-x (supports Lua alongside C++ and JavaScript)
- Solar2D (formerly Corona SDK, Lua-centric for 2D games)
- OpenMW (Morrowind engine with Lua modding)

Honestly, I have no idea what most of these engines are, except Love2D it’s awesome. I’m no game engine expert, but clearly, Lua is everywhere.

According to Google, here are more games using Lua:

- Garry’s Mod—Lua drives most modding and gameplay.
- Roblox—uses a Lua dialect called Luau.
- Angry Birds—core logic is Lua.
- Terraria (tModLoader)—modding via Lua.
- Don't Starve—Lua for modding and game logic.
- Dark Souls series—Lua noscripts some AI.
- The Sims 4—powers game mechanics.
- Far Cry series (pre-Far Cry 3)—heavily noscripted with Lua.
- RimWorld (partially via Harmony modding).
- Payday 2—mods are Lua-based.
- Teardown—Lua for modding.

## DevOps & Systems programming

Lua isn’t just for games. It’s also in sysadmin tools:

- Nginx—uses Lua for dynamic configurations.
- Redis—supports Lua server-side noscripting.
- Tarantool—in-memory database.
- AwesomeWM—a Lua-based window manager.
- Syslog-ng—logging with Lua.
- HAProxy—Lua noscripting.
- OpenWrt—router firmware.

Lua doesn’t replace Python, Bash, or Go in DevOps, but it fits where speed, embeddability, and a tiny footprint matter.

## C’s Best Friend

Lua was built to be embedded. If you’re writing BlAzInG FaSt apps in C/C++, Lua adds flexibility without sacrificing BlAzInG FaSt.

## Should You Learn It?
Don’t forget, even though Lua is super small, it’s still a different language. For broadening your horizons it’s an interesting, if you have time, why not? There’s also Nelua, an interesting project, but it’s not nearly as widespread as Lua.

If you’re a default web monkey shuffling JSONs on the server and happy with that, Lua won’t make you better or worse. But exploring it might just
noscript help

i've made a car but i want cylinders that are transparent and are sand orange to come out the wheels and get bigger for 3 seconds before they despawn to add a cool effect when going really fast, how do i do that i only model not code?

https://redd.it/1ipkxkh
@r_lua
UserInputService is underlined and I don't know why... I'm trying to get my sons game to let players run. Please help. He is so proud of what he's made so far and i'm helping him learn coding. He is 7 years old
https://redd.it/1ips4di
@r_lua
LUA decryption

Hello Guys i need a help i have a noscript which is Lua format when i open it, weird symbols and searched the internet top to bottom way to decrypt the file can anyone help me with it and tell me how to do it tried too many things anyone help please and appreciate the help in advance

https://redd.it/1ipvhvy
@r_lua
Is it possible to create a TUI using Lua?

I am interested in developing a TUI that uses Lua and Bash to color text in the terminal, but I don't know how to get started or if this is possible.

https://redd.it/1iq1xpm
@r_lua
How can I actually learn Lua/Luau?

Hello. I wanted to ask. How can you actually learn Lua or Luau. I really want to find an easy and free way to learn programming for especially Lua and Luau. I was thinking about something like Codecademy which when I tried out, it actually worked pretty well. But I wonder if there are any other ways that aren't just long and boring articles. Of course the first thing that comes to mind is Youtube, which is understandable, but is there actually anything else that can teach kind of like Codecademy? That kind of teaching is what comes to my mind when I want to learn a programming language. It's not boring and you actually get to code while it gives you tips, and it's fun. I want to learn just how to code in Lua entirely, as well as learn everything in Luau so I can get to Roblox developing. Thanks.

https://redd.it/1iqdsvk
@r_lua
Ajuda no Script Lua

Hi guys, I need some help, I'm trying to make this noscript activate on the mouse button (5) and deactivate on (4) but I can't, could someone help me?



function OnEvent(event, arg)

OutputLogMessage("event = %s, arg = %d\\n", event, arg)

if (event == "PROFILE_ACTIVATED") then

EnablePrimaryMouseButtonEvents(true)

elseif event == "PROFILE_DEACTIVATED" then

ReleaseMouseButton(4) -- to prevent it from being stuck on

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == 5) then

recoil = not recoil

spot = not spot

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil) then

if recoil then

spot = not spot

repeat

Sleep(3)

MoveMouseRelative(0,7)

Sleep(9)

MoveMouseRelative(0,3)

Sleep(12)

MoveMouseRelative(0,14)

Sleep(25)

until not IsMouseButtonPressed(1)

end

end

end

https://redd.it/1iqwkzc
@r_lua
Help Script lua

I posted it again because for some reason my post became unavailable. I wanted someone to change this noscript to activate on mouse button (5) and deactivate on mouse button (4), because I tried and couldn't do it. I would appreciate it if anyone could make the change.



function OnEvent(event, arg)

OutputLogMessage("event = %s, arg = %d\\n", event, arg)

if (event == "PROFILE_ACTIVATED") then

EnablePrimaryMouseButtonEvents(true)

elseif event == "PROFILE_DEACTIVATED" then

ReleaseMouseButton(2) -- to prevent it from being stuck on

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == 4) then

recoil = not recoil

spot = not spot

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil) then

if recoil then

spot = not spot

repeat

Sleep(3)

MoveMouseRelative(0,7)

Sleep(9)

MoveMouseRelative(0,3)

Sleep(12)

MoveMouseRelative(0,14)

Sleep(25)

until not IsMouseButtonPressed(1)

end

end

end

https://redd.it/1iqz975
@r_lua
Confusion on local variables

Learning lua for fun but confused by local varibles. So I get that local varibles are limited to the code block they are in. But if you make a local varible like this

local name = “jack”

print(name)

In the code the varible can be accessed from anywhere in the program. Does this not defeat the purpose of a local varible as now you can access it from anywhere ? Why not just make this varible global ?

https://redd.it/1irvcd7
@r_lua
Learning

I want to learn Lua. What's the best way to start? Should I just watch YouTube tutorials, or should I try some websites first?

https://redd.it/1it6osp
@r_lua
How Lua Scripting in Redis Ensures TBMQ as a High-Performance MQTT Broker

Achieving 8,900 messages per second per CPU core and scaling to 1 million messages per second—with even more capacity on the horizon. By migrating from Postgres to Redis for persistent MQTT sessions and leveraging Lua noscripting, we eliminated a major performance bottleneck.

In our latest blog post, we share the challenges we faced and the architectural decisions that led to these impressive results. We also explain how Lua noscripting in Redis can optimize persistent caching layers, dramatically offloading database workloads. This enables real-time processing with minimal latency and guaranteed delivery, improving both scalability and performance.

Whether you’re a software engineer looking for technical ideas and patterns or a manager aiming to future-proof the infrastructure of your system, you’ll find valuable insights to enhance your system efficiency and make it reliable and scalable. 

Read the full story on our blog to learn how we achieved these breakthroughs.

Ready to try it out? Check out our GitHub.

https://redd.it/1it9kj3
@r_lua
Need help with scaling object speed to player score

Hi there - very new to programming. Only started learning Lua a few days ago.

I am at the stage where I've been trying to tweak the code of a 'Pong' tutorial I followed to make it my own. The basic idea is that you control a cheeseburger trying to escape a fat guy. The fat guy is programmed to always pursue the player. Player score goes up in seconds, with it resetting everyone's positions if the fat guy makes contact with the player.

I have finally got everything to work, except I am having real trouble scaling the fat guys speed to make the game harder the longer you survive.

Here is the code for my fat guy:

Carson = {}



function Carson:load()

self.img = love.graphics.newImage("assets/CARSON.jpg")

self.width = self.img:getWidth()

self.height = self.img:getHeight()

self.x = love.graphics.getWidth() / 1.5

self.y = love.graphics.getHeight() / 2 - (self.height / 2)

self.speed = 90

self.xVel = -self.speed

self.yVel = 10

end



function Carson:update(dt)

Carson:chasePlayer(dt)

speedBoost(dt)

end



function speedBoost(dt)

self.speed = self.speed + Score.score

end



function Carson:chasePlayer(dt)

if self.x + (self.width / 2) > Player.x + (Player.width / 2) then

self.speed = -self.speed -- Possibly irrelevant code

self.x = self.x + self.xVel * dt

elseif Player.x + (Player.width / 2) > self.x + (self.width / 2) then

self.x = self.x + -self.xVel * dt

end



if self.y + (self.height / 2) > Player.y + (Player.height / 2) then

self.y = self.y + self.xVel * dt

elseif Player.y + (Player.width / 2) > self.y + (self.height / 2) then

self.y = self.y + -self.xVel * dt

end

end



function Carson:draw()

love.graphics.draw(self.img, self.x, self.y)

end

I cannot work out for the life of me why this won't work. In theory, I want the function speedBoost() to update the self.speed to whatever it started at, plus the players score (since the players score goes up in seconds, this should result in an enemy whos speed directly scales with how long you've survived). I am pulling Score.score from my main.lua file in love.load():


function love.load()

Player:load()

Carson:load()



Score = {score = 0, highscore = 0}

font = love.graphics.newFont(30)

end

However when I try and boot the game I'm getting: carson.lua:20: attempt to index global 'self' (a nil value).


I figured that since I have Carson:update(dt) in love.update(dt), love.update was attempting to call the self.speed, resulting in the error, so I changed the speedBoost function to:

function speedBoost(dt)

Carson.speed = Carson.speed + Score.score

end

Which allows me to run the game without any error, however the fat guy just doesn't ever get any faster.


Updating self.speed manually to a higher number seems to work fine, but any attempt to automate this by scaling it with the player score or even delta time either gives me an error or the fat guy just doesn't speed up.


What am I missing? I'm driving myself mad.

https://redd.it/1italma
@r_lua
Lua origins and security

At a recent cybersecurity conference, an answer from one of a panelist suggested Lua was a security risk. The question was about device automation and TAA certification of hardware. The panelist referred to QSC, saying that it was off-limits for them (a DoD contractor) because the native language is Lua, and Lua has its origins in Brazil, "a BRICS country". Baffled, I later looked it up and indeed the QSC platform, Q-Sys, uses Lua.

Has anybody ever heard of Lua being classed as a security risk because it originates from Brazil??

https://redd.it/1itdwp1
@r_lua
Lapis Framework

hey! i want to start using the Lapis framework,

I'm a complete beginner in Lua and i have some questions

What version of Lua to use with Lapis? i heard the 5.4 is not the best for Lapis, so which one should I use?

my main OS is windows, should i use a WSL? (to install lua, luarocks & lapis)



https://redd.it/1ithzvp
@r_lua
Anybody figured how to use Luamidi with Love2D on MacOS?

It's giving some errors and it says it can only be compatible with Lua 5.1. I installed that manually but man, it isn't working and giving syntax errors, which mostly indicates compatibility issues with the versions of Lua / LuaMidi and Love2D I'm using (and i think love2D uses LuaJIT) Has anybody figured this out? cuz i'm trying out really stupid but fun projects involving both, and I need my midi input from piano (real-time) to work to get those apps running

https://redd.it/1itsd8r
@r_lua
why does this lua pattern has no match

for word in string.gmatch('camelCase', '^%l+') do
print(word) // camel expected here but nothing
end


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