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
question from complete beginner about for loops

https://preview.redd.it/lf9ecc7rutee1.png?width=1920&format=png&auto=webp&s=335377fa473beea58aca5a3ce37b0ed19a59d5e9

hi, i am a complete beginner in both lua and programming in general. i was just wondering if there is a way to make a variable using for loops (as you can see i'm repeating the same loop multiple times)

sorry if this has been asked before, i didn't really know what to search for on google for my question, thanks!

https://redd.it/1i8hanw
@r_lua
Matching markdown tables (regex)

I have a Lua noscript that parses MediaWiki markdown tables. It works great for "flat" tables where the elements in a row are all inline and separated with double pipes, but I'm having trouble making a separate noscript to deal with tables with each field on a different line such as this:

|-
| Game ABC
|{{untested}} <!-- xefu -->
|{{untested}} <!-- xefu2 -->
|{{untested}} <!-- xefu3 -->
|{{untested}} <!-- xefu5 -->
|{{untested}} <!-- xefu11 -->
|{{untested}} <!-- xefu6 -->
|{{playable}} <!-- xefu7 -->
|{{untested}} <!-- xefu7b -->
|{{untested}} <!-- xefu2019 -->
|{{untested}} <!-- xefu2021a -->
|{{untested}} <!-- xefu2021b -->
|{{untested}} <!-- xefu2021c -->
| Name Here
| Notes Here
|-
| Another Game
|{{menus}} <!-- xefu -->
|{{untested}} <!-- xefu2 -->
|{{menus}} <!-- xefu3 -->
|{{untested}} <!-- xefu5 -->
|{{untested}} <!-- xefu1
1 -->
|{{menus}} <!-- xefu6 -->
|{{menus}} <!-- xefu7 -->
|{{menus}} <!-- xefu7b -->
|{{untested}} <!-- xefu2019 -->
|{{untested}} <!-- xefu2021a -->
|{{untested}} <!-- xefu2021b -->
|{{untested}} <!-- xefu2021c -->
| Names Here
| Notes Here
|-

I'm interested in taking the info between two different |- as one entry.

I feel like I'm close, but having trouble since Lua doesn't seem to support lookahead or non-capture groups:

for row in wikitable:gmatch("|%-(.-)|%-") do

https://redd.it/1i9gn5f
@r_lua
Lua Powered Remote Garage Door Controller

This Lua-powered DIY DoorController project provides a web-based solution for controlling a garage door remotely. It includes a minimally invasive design with a magnetic reed switch for detecting door states and an NPN transistor for simulating button presses on a generic garage door remote. The software provides a web interface that can be added to mobile home screens for app-like functionality. The project also supports email garage door open/close state logging by configuring SMTP settings.

Project link: https://github.com/jjsch-dev/DoorController

https://redd.it/1i9ujlv
@r_lua
how to install luarocks on windows

I have done it before with the use of this installer, but I want to do it manually so I can customize stuff. The installer works, but it creates problems with my C++ installation.

Few requirements for the install:
Must be on a different hard drive with the packages also on that drive
Must not come with lua install as well. I want to use one I already have installed
Must like work or whatever

so how can i install it?


(also side note does it work with luau?)

https://redd.it/1i9tqxt
@r_lua
[SOLVED] "legacy sigalg disallowed or unsupported" error when emailing with LuaSocket

I have been emailing from Lua for a long with with the code on [this page](https://stackoverflow.com/questions/11070623/lua-send-mail-with-gmail-account/11070674). After updating Debian to Bullseye I got the error in the noscript, which was not at all helpful. After a lot of digging, it turned out that it is related to newer versions of OpenSSL.

The fix is to change the line:

`sock = ssl.wrap(sock, {mode='client', protocol='tlsv1'})`

to

sock = ssl.wrap(sock, {mode='client', protocol='tlsv1_2'})

I’m posting this for people to find later.

https://redd.it/1ia79k7
@r_lua
Script no recoil Logitech pour SCUM

Yo je cherche quelqu'un qui serait susceptible de m'aidé ..
a faire un noscript no recoil pour une armes ou deux sur scum en particulier l'ak47 avec p-223 et pour la rpk avec p-223 évidemment il faudrait que l'ont puissent changé les valeur en fonction de la force que l'ont a
Je sais que c'est peu être pas si simple mais j'espère trouvé quelqu'un qui puisse m'aidé vraiment .. !

https://redd.it/1iaexgh
@r_lua
Have fun, I hope someone can help with writing the macro. For game Rust ak47 new rec, in foto
https://redd.it/1iaw8f4
@r_lua
Lua noscript

Can someone help me learn how to make noscript that will do rapid fire in any fps games

https://redd.it/1iboynh
@r_lua
Lumorphix Processor IP Core - Scriptable with Lua

See the product page, documentation, beta release info and / or mailing list.

More to come... will keep you guys posted (if interested ?)

https://redd.it/1iboc2n
@r_lua
Does LUA seem... A little odd?

So I have some experience with this language but not a ton. I used it in a the context of a mod for satisfactory called ficsit networks. I created a factory that allowed you to request a certain number of a certain item and it would be automatically crafted. This was actually deliciously complicated. I had several coroutines acting to make this happen and the project was really fun but I never really finished it.

Recently I revisited it and I ran into what, in my opinion, is one of the downsides of lua. It has a minimalist aesthetic that makes it pretty easy to write. But old code that you haven't seen for a while looks like it was written by an alien. This is in spite of the copious comments I wrote.

It sort of stopped me dead in my tracks in a way that old python, c#, vba or java code never would have. And to be clear... I wrote this code.
I do this for a living... Not Lua... Obviously. But has anyone else experienced this more acutely with Lua than other languages? For me, the language is really hard to read because it's so minimal. Plus the fact that its somewhere between object oriented and not and the weirdness with the tables.... This is an odd language. I guess I need someone to tell me I'm not crazy.

https://redd.it/1ibxwnq
@r_lua
why does it say unexpected symbol when I run a noscript on Hammerspoon? it says [string "#SingleInstance Force..."]:1: unexpected symbol near '#'. anyway I know nothing about code lol help much appreciated.

https://redd.it/1ic193a
@r_lua
Is this a good way of trimming user input? There's an option to paste from clipboard as well and that goes over the limit
https://redd.it/1ic2ghs
@r_lua
Help understanding tables

Hi all,

I'm writing Lua for a boat's navigation computer in the game Stormworks. The computer takes coordinate inputs from multiple sources (internal gps, transponder locator, radar, keyboard) and writes them to the indices of table p. Each index of p represents a point on the map, the rows within contain data about that point, for example p[9\][x\]=boat's x coordinate, p[9\][y\]=boat's y coordinate, p[9\][db\]=boat's distance to boat (will always be 0), p[9\][id\]="b". Once the table has been populated I want to remove any index from the table where p[i\][x\]==nil so that I don't need to deal with them when rendering the points on a map. I also want to sort them by db for easy readability in the UI. If my understanding of Lua is correct (low chance I know) p will effectively always have some nil x/y values associated with a non nil index because I need to declare each row of p[i\] before I can set its coordinates. With all that in mind, can someone please explain the behavior of my code in the following cases:

1. https://onecompiler.com/lua/437eb2qbg in this instance I have left out the table.remove() function. Sorting works as expected. This is just here to compare against the next two examples
2. https://onecompiler.com/lua/437e8w65y here I try to remove indices with nil x values before the sorting step. I don't know why a nil index is being called by the getDist function, it seems to me that the table should have no nil values after the removal step, so what gives?
3. https://onecompiler.com/lua/437eb7yn8 here I remove indices with nil x value after the sort. You can see that three of the nil values have been removed, three have remained. I assigned p[i\][id\] here in the radar loop to see if the values that get dropped are random. Strangely, it appears that r4, r5, and r7 always get removed.

Questions I have anticipated:

Q: Does this post violate rule 8?

A: No, Stormworks gives players the ability to write Lua for their components in an in game editor, this is intended functionality by the devs.

Q. Surely someone has made a working navigation computer in Stormworks, why not just download someone else's from the workshop?

A. I would rather die.

Q. Why does getDist() return 999999999 for nil parameters instead of nil?

A. returning nil breaks my sort. I tried to handle nils in the sort function but that did not work at all. If you have pointers here I would be very happy to hear them. The map is way smaller than 999999999 so I'll never mistake that value for real data.

Q. Ok then why don't you just set all nil values as 999999999 then?

A. It seems lazy. That's what I will do if ya'll think it's the right way of handling this problem, but it feels very unga-bunga to me. Like I said above I'd rather never return a dummy value, I just don't know enough yet to avoid it

Thanks in advance! This is my first post here, hopefully the onecompiler links properly abide by rule 5.


>Edit: Spelling

https://redd.it/1ic8196
@r_lua
How to Install Lua on Windows

If you're still stuck on Windows like me, these steps might help you install Lua. At least, they worked for me.

1. Download the Windows x64 Executables (or x86, if applicable) for Lua from https://luabinaries.sourceforge.net/download.html
2. Extract the contents into a folder named "lua"
3. Move the "lua" folder to "C:\\Program Files" (or "C:\\Program Files (x86)" if you downloaded the x86 version)
4. Inside the folder, rename "lua53.exe" to "lua.exe" so that you can run it simply as `lua` instead of `lua53` (You might have a newer version, but I am using LuaBinaries 5.3.6).
5. Copy the folder path ("C:\\Program Files\\lua" or "C:\\Program Files (x86)\\lua") and add it to the PATH environment variable. (You know how to do this, right?)
6. Verify the installation by opening the Command Prompt and running: `lua`

https://redd.it/1icuoql
@r_lua
Can anyone explain why this code doesnt work ? i wrote the code in the newest lua version.

local userpassword = {}
local generated
password = {}

function randpasswordgenerate()
    repeat
        table.insert(generatedpassword,table.concat(string.char(math.random(60,116))))
    until user
passwordmath.random(8, 16) ~= nil    

end

userpassword = generatedpassword

https://redd.it/1icywvh
@r_lua
I am Interested in Learning lua

i am interested in learning lua but don't know where to start. what should i learn first and in what order should i learn first in lua and for context i know java java noscript python and html. if that make's it easier for choosing how i should learn thank you for considering in advance

https://redd.it/1id3nex
@r_lua
Ban posts asking for help to learn Lua

There's been too many posts like "help learn lua" "best way to learn lua" "where do I learn"

God damn. 50% of the posts are asking the exact same. All you have to do is search this subreddit before posting a question.

You will find plenty of online resources for learning. Don't flood this subreddit with those questions. Ask questions that haven't been asked before, that way you add value to this subreddit.

Mods, do something about it.

https://redd.it/1idin6j
@r_lua
Book

Are there any books for lua? (Price 10 - 20$) I love readinng books and most of the time i remember alot from them so reading them could help me learn the language.

https://redd.it/1iduhhu
@r_lua
Mesh modification?

I want to make a little noscript that takes in an FBX mesh (or other 3d model type) and assuming it is a cube, each side would represent (what i call) 1 "unit." It would then generate and save all size variations of this mesh going from 1x1x1 units (the starting size) to 8x8x8. In the end, the folder that had the 1x1x1 mesh now has all 512 different size variations of it. If the input were a wedge/slope with the same bounding box, it would also output all size variations of it, so it isnt limited to cubes.

But what can I do to modify the mesh in the first place? I cant find any luarocks modules to use, (or they exist and im not looking closely) nor do I know how to do it manually.

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