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
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
What would you add to my Lua code?

I am starting in programming and I made this small game for the user to guess the right number, and I would like to know what you, as an intermediate or advanced programmer, would add to my code.

print([

('-. .-') .-') .-') _ _ .-') .-. .-') ('-. _ .-')
_( OO) ( OO ). ( OO ). ( OO ) ) ( '.( OO )_ \ ( OO ) _( OO)( \( -O )
,----. ,--. ,--. (,------.(_)---\_)(_)---\_) ,--./ ,--,' ,--. ,--. ,--. ,--.);-----.\(,------.,------.
' .-./-') | | | | | .---'/ _ | / _ | | \ | |\ | | | | | `.' | | .-. | | .---'| /`. '
| |_( O- )| | | .-') | | \ :` `. \ :` `. | \| | )| | | .-') | | | '-' /_)| | | / | |
| | .--, \| |_|( OO )(| '--. '..`''.) '..`''.) | . |/ | |_|( OO )| |'.'| | | .-. `.(| '--. | |_.' |
(| | '. (_/| | | `-' / | .--' .-._) \.-._) \ | |\ | | | | `-' /| | | | | | \ || .--' | . '.'
| '--' |(' '-'(_.-' | `---.\ /\ / | | \ | (' '-'(_.-' | | | | | '--' /| `---.| |\ \
`------' `-----' `------' `-----' `-----' `--' `--' `-----' `--' `--' `------' `------'`--' '--'
])
local number = math.random(1, 100)

io.write("Type a number: ")
local guess = tonumber(io.read())

if guess == number then
print("\nCongratulations")
elseif guess ~= number then
while guess ~= number do
if number > guess then
print("\nTry a higher number")
io.write("Type a number: ")
guess = tonumber(io.read())
if guess == number then
print("\nCongratulations you guessed the number!\n")
end
elseif number < guess then
print("\nTry a smaller number")
io.write("Type a number: ")
guess = tonumber(io.read())
if guess == number then
print("\nCongratulations you guessed the number!\n")
end
end
end
end


https://redd.it/1iv3p2y
@r_lua
Trying to make an 'or' entry, please help me out?

Hi guys,

For a personal mod in Assetto Corsa, I'm trying to let a LUA file - that switches on the app when it sees to right car - look for not one, but two cars: the 2025 car and the 2024 car.
Nothing I do seems to work:
" , "
" or "
making the 5 (or 4) into %s

These are the lines; can someone please point me in the right direction?



if string.startsWith(ac.getCarID(0), "formula_2_2025") then appActive = true

local function optimizeCarModel(car)
if ac.getCarID(car.index) ~= "formula22025” then
return
end

https://redd.it/1ivh7sg
@r_lua
Dluau: luau runtime focused on extensibility and modularity

Project link

A personal project i've been working on. Luau is a great variant of lua in my opinion, but its support for dynamically extending the environment has always been limited. This project tries to bridge that gap a little on top of some other extra quality-of-life features.

The project is subdivided into a minimal core, which exports all the Luau C API symbols as well as some extra API for registering userdata tags, namecall atoms and types in a dynamic library friendly way. And a standard library (which is kinda all over the place at the moment) which you can optionally use.

Statically resolves noscript, DLL and standard library dependencies at startup of the runtime only loading the dependencies you are actually using. Then sandboxes these resources.

Any tips, feedback, suggestions or critique would be greatly appreciated.

https://redd.it/1ivtmij
@r_lua
Lua Game Engine export multi platform application only bytecode

Hello

I'am looking for a recommendation of a (2D) Lua game engine which can be used to develop games.

I want a multi platform export of the application but with only bytecode in the bundle/package (I don't want to ship the Lua source code in the bundle/package).

Any recommendation?

Thank you

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