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
Is there a standard package manager for lua?

Hello, I come from a coding background, but am new to lua(only ever wrote noscripts for aseprite).

I'm curious is there a standard package manager for lua?
ala bundler for ruby or mix for elixir.

Some context, I found a pretty cool looking game engine(love) and figured I'd make something to get a feel for it. The getting started guide suggests installing it system wide which seems bad and some quick googling for a package manager produced multiple results, so I wasn't sure where to start.

Figured it might be a dumb question with an obvious answer so worth asking before I research it myself.

Thank you everyone for the help.

https://redd.it/1hfmptw
@r_lua
Code Error - Need Help!

Received an error on line 14 code in Trading Station, which uses Lua. The error states "Colon (;) expected here." Here is the code through line 14. Does any one have any thoughts?


\-- ICT Breaker Block Algorithm for Trading Station

\-- Time Windows: 9:20-9:40 AM, 10:20-10:40 AM, 10:50-11:10 AM EST



\-- Parameters

local lookback = 20 -- Lookback period for swing high/low detection

local riskRewardRatio = 2 -- Risk-reward ratio for take profit

local timeWindows = {

{start = "09:20", end = "09:40"},

{start = "10:20", end = "10:40"},

{start = "10:50", end = "11:10"}

}



\-- Variables

local swingHighs = {}

local swingLows = {}

local breakerBlock = nil

local entryPrice = nil

local stopLoss = nil

local takeProfit = nil



\-- Helper function to check if the current time is within the allowed time windows

function isWithinTimeWindow(currentTime)

for _, window in ipairs(timeWindows) do

if currentTime >= window.start and currentTime <= window.end then

return true

end

end

return false

end



\-- Initialize the strategy

function Init()

strategy:name("ICT Breaker Block Strategy for NQ")

strategy:denoscription("Executes trades based on ICT Breaker Block concept during specific time windows.")

strategy.parameters:addInteger("Lookback", "Lookback period for swing high/low detection", "", lookback)

strategy.parameters:addDouble("RiskRewardRatio", "Risk-reward ratio for take profit", "", riskRewardRatio)

end

https://redd.it/1hg0d6f
@r_lua
Looking for a Lua Fullstack Developer - Serverless Web Apps for a German Startup

Hey everyone, i've posted here a couple of times about the platform that the startup i work for is developing.

It's a german startup called Tenum and we're looking for a Lua fullstack developer (preferably as a freelancer) to help us build serverless web applications on our platform. The platform is still under development, but already a great experience to get things done fast.

If you have solid experience with Lua and web development and would like to work with a new technology on various customer projects, I'd love to hear from you.

This would be the ideal process:

1. After you've contacted me here on Reddit or via email, we'll set up a quick call with the founder.
2. Then we'll show you the platform and discuss the details.
3. If there's a fit, we'll start working together.

We'd prefer someone whose time zone is well aligned with ours (CET).

If you're interested, dm me or email me at hello@tenum.ai with a short note about yourself and your experience.

Thanks a lot!

https://redd.it/1hgenoi
@r_lua
Logitech g hub Lia noscripts not working on steam but work on Ubisoft. Why is that?

Can somone help me with my lua noscripts they will not work when I launch the game through steam?

https://redd.it/1hgjsn2
@r_lua
Beginning

I really want to start Lua as a hobby to make games but have absolutely no idea on where/how to start. Anyone please help me.

https://redd.it/1hgnv52
@r_lua
Short Ai

Hi everybody, I made a small ai that kinda works. You can use it by using copy and pasting it and typing in the console commands like “I like dancing” or “I hate cats.”
math.randomseed(os.time()) -- Randomize for variability

-- Memory system to store user preferences
local memory = {}

-- Expanded knowledge base with new categories
local knowledgeBase = {
greetings = {
{ word = "hello", response = "Hey there! How’s it going?" },
{ word = "hi", response = "Hi! What’s up?" },
{ word = "hey", response = "Hey! How are you?" }
},
farewells = {
{ word = "bye", response = "Goodbye! See you soon." },
{ word = "goodbye", response = "Take care! Until next time." }
},
affirmatives = {
{ word = "yes", response = "Alright! That sounds good to me." },
{ word = "sure", response = "Sure thing!" }
},
negatives = {
{ word = "no", response = "That’s okay, maybe next time." },
{ word = "never", response = "Fair enough, we’ll leave it at that." }
},
commonwords = {
{ word = "I", response = "Tell me more about yourself!" },
{ word = "the", response = "Got it! Let's keep going." },
{ word = "and", response = "Alright, I’m listening!" },
{ word = "a", response = "That’s interesting! Keep going." }
},
emotions = {
{ word = "happy", response = "It’s great to hear you’re happy!" },
{ word = "sad", response = "I’m here for you if you want to talk." },
{ word = "excited", response = "Excitement is contagious! Tell me more!" }
},
actions = {
{ word = "run", response = "Running is a great way to stay fit!" },
{ word = "walk", response = "A nice walk can clear your mind." },
{ word = "jump", response = "Jumping around sounds fun!" }
},
animals = {
{ word = "dog", response = "Dogs are amazing companions!" },
{ word = "cat", response = "Cats can be so playful and curious!" },
{ word = "lion", response = "Lions are truly majestic creatures." }
},
nature = {
{ word = "mountain", response = "Mountains are breathtaking, aren’t they?" },
{ word = "river", response = "Rivers bring such peace and beauty." },
{ word = "forest", response = "Forests are full of life and mystery." }
},
colors = {
{ word = "red", response = "Red is such a bold and vibrant color!" },
{ word = "blue", response = "Blue always feels calm and peaceful." },
{ word = "green", response = "Green reminds me of nature and life!" }
}
}

-- Split input into words
function splitWords(input)
local words = {}
for word in input:lower():gmatch("%S+") do
table.insert(words, word)
end
return words
end

-- Find matches in the knowledge base
function findMatches(words)
for
, inputWord in ipairs(words) do
for , entries in pairs(knowledgeBase) do
for
, entry in ipairs(entries) do
if inputWord == entry.word:lower() then
return entry.response
end
end
end
end
return nil
end

-- Update memory system
function updateMemory(words)
local memoryKeywords = { "like", "love", "enjoy", "hate", "dislike" }
for i, word in ipairs(words) do
for , key in ipairs(memoryKeywords) do
if word == key and words[i + 1] then
local topic = words[i + 1]
memory[topic] = key
return "Got it! I’ll remember you " .. key .. " '" .. topic .. "'."
end
end
end
return nil
end

-- Generate response
function generateResponse(words)
-- Update memory if user specifies preferences
local memoryResponse = updateMemory(words)
if memoryResponse then return memoryResponse end

-- Find and return a response if a match exists
local response = findMatches(words)
if response then
return response
end

-- Check memory for known topics
for
, word in ipairs(words) do
if memoryword then
return "You told me you " .. memoryword .. " '" .. word .. "'. Do you still feel that way?"
end
end

-- Fallback response
return "Hmm, I’m not sure about that. Can you tell me more?"
end

-- Main Loop
print("AI Chat: Just type anything, and I’ll respond! Type 'exit' to quit.")
while true do
io.write("> ")
local input = io.read()
if input:lower() == "exit" then
print("Goodbye! Have a great day!")
break
else
local words = splitWords(input)
print(generateResponse(words))
end
end


https://redd.it/1hgot1a
@r_lua
Downgrade lua 5.3 para lua 5.1 e luarocks

# Atualmente eu estou usando lua 5.3 já instalei alguns apps nele como vlc, neovim, etc

# Quero saber se existe uma maneira de desinstalar o 5.3 e instalar o 5.1 sem quebrar os pacotes já instalado. ai vem a pergunta porque quero dar um downgrade estou tentando renderizar imagens no meu terminal kitty com plugin do neovim eu consigo já redenrizar com terminal puro mas sempre tenho problemas porque o plugin do neovim só funciona com lua 5.1 e eu já uso o 5.3 a um bom tempo. Alguem tem alguma dica do que fazer?

https://preview.redd.it/dnnp8bv20i7e1.png?width=843&format=png&auto=webp&s=e540b789d1f66cfd0f8050d80c269683efd2cbbd

https://preview.redd.it/as31cagy0i7e1.png?width=1210&format=png&auto=webp&s=8a968393a5fc9fbb23303adac0006863ad42b994




# Um exemplo do terminal renderizando puro e um exemplo de como fica meio bugado dentro do neovim mesmo não acusando erro no neovim nem no luarocks. Abaixo o exemplo da minha configuracao do plugin 3rd https://github.com/3rd/image.nvim

--
-- Filename: ~/github/dotfiles-latest/neovim/neobean/lua/plugins/image-nvim.lua
-- ~/github/dotfiles-latest/neovim/neobean/lua/plugins/image-nvim.lua

-- For dependencies see
-- ~/github/dotfiles-latest/neovim/neobean/README.md
--
-- -- Uncomment the following 2 lines if you use the local luarocks installation
-- -- Leave them commented to instead use luarocks.nvim
-- -- instead of luarocks.nvim
-- Notice that in the following 2 commands I'm using luaver
-- package.path = package.path
-- .. ";"
-- .. vim.fn.expand("$HOME")
-- .. "/.luaver/luarocks/3.11.05.1/share/lua/5.1/magick/?/init.lua"
-- package.path = package.path
-- .. ";"
-- .. vim.fn.expand("
$HOME")
-- .. "/.luaver/luarocks/3.11.0
5.1/share/lua/5.1/magick/?.lua"
--
-- -- Here I'm not using luaver, but instead installed lua and luarocks directly through
-- -- homebrew
-- package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?/init.lua"
-- package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?.lua"
-- Configuração para Lua 5.1 no Arch Linux
package.path = package.path
.. ";"
.. vim.fn.expand("$HOME")
.. "/.luarocks/share/lua/5.1/magick/?/init.lua"
.. ";"
.. vim.fn.expand("$HOME")
.. "/.luarocks/share/lua/5.1/magick/?.lua"
.. ";"
.. "/usr/share/lua/5.1/?.lua"
.. ";"
.. "/usr/lib/lua/5.1/?.lua"

package.cpath = package.cpath
.. ";"
.. vim.fn.expand("$HOME")
.. "/.luarocks/lib/lua/5.1/?.so"
.. ";"
.. "/usr/lib/lua/5.1/?.so"

return {
{
-- luarocks.nvim is a Neovim plugin designed to streamline the installation
-- of luarocks packages directly within Neovim. It simplifies the process
-- of managing Lua dependencies, ensuring a hassle-free experience for
-- Neovim users.
-- https://github.com/vhyrro/luarocks.nvim
"vhyrro/luarocks.nvim",
-- this plugin needs to run before anything else
priority = 1001,
opts = {
rocks = { "magick" },
},
},
{
"3rd/image.nvim",
enabled = true,
dependencies = { "luarocks.nvim" },
config = function()
require("image").setup({
backend = "kitty",
kittymethod = "normal",
integrations = {
-- Notice these are the settings for markdown files
markdown = {
enabled = true,
clear
ininsertmode = false,
-- Set this to false if you don't want to render images coming from
-- a URL
downloadremoteimages = true,
-- Change this if you would only like to render the image where the
-- cursor is at
-- I set this to true, because if the file has way too many images
-- it will be laggy and will take time for the initial load
onlyrenderimageatcursor = true,
-- markdown extensions (ie. quarto) can go here
filetypes = { "markdown", "vimwiki", "html" },
},
neorg = {
enabled = true,
clearininsertmode = false,
download
remoteimages = true,
only
renderimageatcursor = false,
filetypes = { "norg" },
},
-- This is disabled by default
-- Detect and render images referenced in HTML files
-- Make sure you have an html treesitter parser installed
-- ~/github/dotfiles-latest/neovim/neobean/lua/plugins/treesitter.lua
html = {
enabled = true,
only
renderimageatcursor = true,
-- Enabling "markdown" below allows you to view html images in .md files
--
https://github.com/3rd/image.nvim/issues/234
-- filetypes = { "html", "xhtml", "htm", "markdown" },
filetypes = { "html", "xhtml", "htm" },
},
-- This is disabled by default
-- Detect and render images referenced in CSS files
-- Make sure you have a css treesitter parser installed
-- ~/github/dotfiles-latest/neovim/neobean/lua/plugins/treesitter.lua
css = {
enabled = true,
},
},
max
width = nil,
maxheight = nil,
max
widthwindowpercentage = nil,

-- This is what I changed to make my images look smaller, like a
-- thumbnail, the default value is 50
-- maxheightwindowpercentage = 20,
max
heightwindowpercentage = 40,

-- toggles images when windows are overlapped
windowoverlapclearenabled = false,
window
overlapclearftignore = { "cmpmenu", "cmpdocs", "" },

-- auto show/hide images when the editor gains/looses focus
editor
onlyrenderwhenfocused = true,

-- auto show/hide images in the correct tmux window
-- In the tmux.conf add `set -g visual-activity off`
tmux
showonlyinactivewindow = true,

-- render image files as images when opened
hijackfilepatterns = { ".png", ".jpg", ".jpeg", ".gif", ".webp", ".avif" },
})
end,
},
}

https://redd.it/1hgon09
@r_lua
What’s the difference between “else” and “elseif”?

I am a beginner who just recently started learning off YouTube.

Most of the things I can make out what they mean after watching some videos

But I still don't understand the meaning of the "elseif" statement

I know some degree of visual programming (scratch...), so I for sure know what the "if" and "else" statement means.

But for "elseif", I don't quite understand what the statement does

Like I can say things like

>variable = 2

>if variable == 1 then

> print("blah")

>else

> print("blee")

(correct me if I made a mistake in my example)

Something like this

I figured if I use "elseif", the results will be the same

So what's the purpose of the "elseif" statement?

https://redd.it/1hgurz3
@r_lua
Where to start?

I want to start Lua for fun so I can program on Roblox, I really want to start learning but don’t know where to start. Most coding websites just throw you straight in, but I want the ABSOLUTE beginner help. What I want is like a website or tutorial on Youtube but I doesn’t matter about platform.

Please!!

https://redd.it/1hgzm21
@r_lua
Can one determine total gc memory allocated?

If I understand correctly, collectgarbage 'count' gives the amount of allocated memory at the time of invocation. Is there a way in standard Lua/LuaJIT to determine the total memory including that previously collected at the time of invocation? That is, is there a way without modifying Lua itself to determine/benchmark how allocation heavy a piece of code is over a particular run? I'm thinking of something like get-bytes-consed from the SBCL Lisp implementation. Something similar to *gc-run-time* might be nice too.

https://redd.it/1hh09uz
@r_lua
My lua noscripts do not work when I launch r6 through steam but when I load up a different account through Ubisoft they work can somone help me get them working for stream?

My lua noscripts do not work when I launch r6 through steam but when I load up a different account through Ubisoft they work can somone help me get them working for stream?

https://redd.it/1hh2yvd
@r_lua
How do i make a configuration file that a lua reads from?

Hi, i want to make my lua noscript read from a .cfg or a .txt or whatever format is the easiest to toggle things inside it's menu

The code for what controls the checkboxes, sliders, dropboxes looks like this:

local Controls = {
checkbox1 = false,
checkbox2 = false,
checkbox3 = false,
checkbox4= true,
Dropdown1 = 1,
Dropdown2 = 1,
Slider1 = 90,
Slider1Input = "",
Slider1Editing = false,
}

What i want is to have somewhere my lua reads from to see what to toggle on and off as a configuration file for the lua noscript, how can i do this, hopefully i gave enough information for people to help me, if not please let me know

https://redd.it/1hi0ur0
@r_lua
hello

https://preview.redd.it/wbn7acdk308e1.png?width=844&format=png&auto=webp&s=d4e48660728fd31ad8b66574865957f04e389313

Hello, I have a problem with the Fivem server because on the paid hosting the noscript package does not work, but on the free one it already works and I keep getting the following error

https://redd.it/1hij6m2
@r_lua
Just a Lil help

Could any Lua/Luau master give me some tips on how to improve my programming? I've already learned a lot from some tutorials on YouTube (a lot). My goal is just to learn enough to be able to create a game on Roblox, as a start, of course.


Thx

https://redd.it/1hivu43
@r_lua
LUA state in 2025?

Hello everyone,

2024 is coming to an end and I'm quite curious about this, what is the current state of LUA in 2025? On the website of LUA, I feel like there's not much of an update. When I search LUA 2024 on Google, the result seems to stop at 2023. There are not many discussions, jobs for LUA also seem to be no result too. So I wonder, what is LUA going to be like in 2025?


The question seems to be vague, I hope you can understand as English is not my first language.

https://redd.it/1hj48nl
@r_lua
I want to build a small forum using Lua.

Hello!
I expressed my purpose in the noscript.
What library would you recommend to use?
Something like Python-Flask.
If it has basic support for creating endpoints, requests and templating I am happy.
I heard Lapis is the most mature.

https://redd.it/1hj9f9f
@r_lua
What is the best way to give a class “private” members?

Giving a class its members in lua implicitly makes them public.

https://redd.it/1hjou4b
@r_lua
Javanoscript "this" function but in lua?

I'm here in roblox getting stuck at this.

Javanoscript has this cool thing here where it is like

function button() {
print(this)
}

And the "this" will show whatever button executed this function, it can be fifty button with that function and it is a cool thing, but what about lua?

Button.TouchSwipe:Connect(function(SwipeDirection, Number, Processed)
print("??")
end)

How the hell do i do it, and roblox lua is a little different than lua right?

https://redd.it/1hk0gvh
@r_lua
Help with inconsistent iterator behavior

I am familiar with the concept of iterators in other languages, but I can't figure out how to get normal iterator behavior out of lua tables. The top example works normally with string iterators, but the bottom does not with table iterators.

-- works
stringEntries = string.gmatch("text1,text2,text3", "(^,+)")
print(stringEntries)
-- function: 0x5627c89b62c0
print(stringEntries())
-- text1

-- does not work
tableEntries = pairs({
    name = {"John", "Jane", "Bob"},
    age = {30, 25, 40},
    city = {"New York", "Los Angeles", "Chicago"}
})
print(tableEntries)
-- function: 0x5627946f14f0
print(tableEntries())
-- stdin:7: bad argument #1 to 'tableEntries' (table expected, got no value)
-- stack traceback:
-- C: in function 'tableEntries'
-- stdin:7: in main chunk
-- C: in ?

I would expect it to return the next key value pair but it's saying the tableEntries iterator expected a table as an argument? What argument would I give to an iterator function created from a table already?

Is there some other normal table iterator function that yields a normal iterator instead of whatever pairs does/does not do?

Edit: Code got repeated twice, removed duplicate, added outputs

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