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
trying to understand index



Crap = { stuff = 42 }
Crap.index = function(table, key)
    return 5
end
print(Crap.stuff)
print(Crap.blah)
print(Crap.oink)

I'm trying to understand __index. It's supposed to be triggered by accessing an element of the table that doesn't exist, right? If it's a function, it calls the function with the table and the missing key as arguments, right? And if it's a table, the access is re-tried on that table, right?

Okay, all the metatable and prototype stuff aside that people do to emulate inheritance, let's first try to get it to run that function...

I cannot figure out why the above code does not get called. The expected outcome is

42
5
5

What I actually get is

42
nil
nil

Why?

If I print something in that function I find that it isn't called.

For that matter, this doesn't work, either...

Crap = { stuff = 42 }
Crap.index = { blah = 5 }
print(Crap.stuff)
print(Crap.blah)
print(Crap.oink)

The expected result is

42
5
nil

What I actually get is

42
nil
nil



https://redd.it/1fzsz0r
@r_lua
What's the point of Lua's boolean type?

Consider the following, which is my understanding of Lua's boolean operators and boolean type:

1. Lua's boolean operators and and or do not require boolean operands, nor do they produce a boolean value. (The way they do work is clear to me, btw.)

2. Lua's conditional expressions do not take a boolean type, but any type. This means there's never a need to convert some truthy-falsey expression (which can be any type in Lua) to an explicit boolean.

3. Even if you wanted to, cleanly converting a value or expression to a boolean is impossible. (Workaround: use 'not not'.)

If my points 1, 2, and 3 are correct, then it seems to me there is no point in having the boolean type in the language.

What say you?


https://redd.it/1fzxjsk
@r_lua
Looking for a programmer

Hey, we are building a Roblox game but our programmer has left , so I'm looking for a programmer with LUA knowledge, feel free to ask me anything, my discord manudiaz27, or leave a comment :D

https://redd.it/1g0oa24
@r_lua
I'm looking for a decrypter for free

I need to bypass moonsec V3 for some reason they ain't important at all btw, I've searched everywhere and can't find a single decrypter, so I'll just look for people who can decrypt stuff, Here is the website that has the code written in it cuz I can't copy it all:

https://raw.githubusercontent.com/Synergy-Networks/products/main/BetterBypasser/publicproduct.lua

,and thanks to all who can help me.

https://redd.it/1g16pyj
@r_lua
How do I run files in Lua?

I recently installed the Lua interpreter for Windows 10 and while I was trying to run a file it didn't let me. I tried various methods and found no solution, even checked if I installed t correctly and I'm sure I did. Can someone please help me, I would aprreciate it.

https://redd.it/1g1rk8e
@r_lua
Help with running a file in Lua

I downloaded the Lua interpreter from Lua Binaries Download (sourceforge.net) and downloaded https://sourceforge.net/projects/luabinaries/files/5.3.6/Tools%20Executables/lua-5.3.6\_Win64\_bin.zip/download, I watched this video on how to install it, (44) How to install and run Lua in Windows - YouTube, I tried the methods in the video, but they did not work. I created a new folder in Documents, then added a text document named main.lua, I typed print("hi") with Notepad, opened PowerShell typed "Lua53 main.lua," entered and received "C:\\Users\\Lina\\Downloads\\Lua\\lua53.exe: cannot open main.lua: No such file or directory." I opened Command Prompt, typed "cd (the address," and pressed enter, typed "lua53 main.lua," after I inputted it again, I had a similar result, "lua53: cannot open main.lua: No such file or directory." I have a Windows 10, 64x bit. I also noticed that the status of the file "main.lua," was still syncing with a blue circle arrow, I'm wondering if this might be the cause. I would appreciate any help with running files.

https://redd.it/1g2dvgg
@r_lua
I've wrote a HTML parse in Lua

Get the inspiration from reading this article https://bvisness.me/luax/.

So I make one that work within Lua, with pragma and transpiler support

https://github.com/syarul/luax

This is a TodoMVC built with using LuaX, Lua, Luasocket and HTMX as sample usage

https://github.com/syarul/todomvc-lua-luasocket-htmx-\_hypernoscript

https://redd.it/1g2ipl4
@r_lua
What's this operator doing?
https://redd.it/1g2ucme
@r_lua
this isnt really something for standard lua. wondering how buffers work in Luau.

im wondering how buffers work in roblox. like i need to learn something new to continue one of my projects i been working on for a while. i have to use many of my compressors are ment for string compression. and i need to find a better method for compressing. can you help?

https://redd.it/1g2w881
@r_lua
Module imports not working with LuaJit

I'm writing a module for a personal project in which I use Penlight, which is installed on a folder inside the project with `luarocks install --tree`, like so:

Project/
| modules/
| bin/
| lib/
| share/
// the usual
| src/
| init.lua
| etc

Inside src/ I have this noscript that requires Penlight, and a simple `local utils = require("pl.utils")` is suficient when running the noscript via `lua noscript.lua`. However when doing the same via luajit I got the following:

/?.lua;/home/linuxbrew/.linuxbrew/share/luajit-2.1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/home/linuxbrew/.linuxbrew/share/lua/5.1/?.lua;/home/linuxbrew/.linuxbrew/share/lua/5.1/?/
init.lua
./?.so;/usr/local/lib/lua/5.1/?.so;/home/linuxbrew/.linuxbrew/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so
luajit: src/dbclass.lua:3: module 'pl.pretty' not found:
no field package.preload['pl.pretty']

I thought "okay, I just need to change path and cpath then" and put:

local version = _VERSION:match("%d+%.%d+")

package.path = f(
"../modules/share/lua/%s/?/?.lua;modules/share/lua/%s/?/init.lua;../modules/share/lua/%s/?.lua;%s", version, version, version, package.path)
package.cpath = f("../modules/lib/lua/%s/?.so;modules/lib/lua/%s/?/?.so;%s", version, version, package.path)

Which worked to recognize the path here Penlight was installed, but now I got an error I'm unfamiliar with and didn't manage to find much help while searching:

luajit: error loading module 'pl.pretty' from file 'modules/share/lua/5.1/pl/init.lua':
modules/share/lua/5.1/pl/init.lua: invalid ELF header

I'll be grateful for any assistance in that regard, I'm yet unfamiliar with ELF libraries, linking and C-related things, so I got a bit lost there.

https://redd.it/1g3q2gj
@r_lua
Has anyone tried to modify lua to allow additional type variants (more than 4 - i.e. 2 bits).... This is my attempt, but Lua becomes unstable.. so I am missing something... anyone know / point me in the right direction ?
https://redd.it/1g44dob
@r_lua
noscript lua for ghub

Hello, I am new to programming. I'm trying to find out how to create a lua noscript to integrate into ghub to define a sequence of actions and mouse movements. Could someone give me a lesson example please? Something like when I click once on g1 the mouse moves to the right by 100 pixels -> right click -> press enter. Thanks for taking your time :D

https://redd.it/1g4bcgi
@r_lua
Nginx json response manipulation

Hi guy
I’ll admit I’m a zero in programming.

I have a problem i tried to solve with ai but I got stuck.


I have a request to a server, and I need to modify the json response before sending it back by adding a field in the json.

It’s driving me insane. Can anyone please help me out?



https://redd.it/1g50rcc
@r_lua
i was running a noscript on logitech ghub and have a new mouse that isnt logitech. is there anyway i can still use the noscript on another software?



https://redd.it/1g5a9nw
@r_lua
Garrys Mod Need Some Help With A Lua Error Im Getting

I seriously need some help with a lua error code im getting with a mod im making, but when i launch the game to go and test my mod it gives me a expected near player lua error everytime i try to test it, Heres the lua error.



[[TFA-VOX\] Sonic The Hedgehog (2010-Present)\] lua/tfa_vox/packs/tfa_vox_sonic_2010_present.lua:83: '}' expected near 'player'

1. TFAVOX_Packs_Initialize - lua/tfa_vox/framework/tfa_vox_packs.lua:120

2. unknown - lua/tfa_vox/framework/tfa_vox_packs.lua:184

3. include - [C\]:-1

4. unknown - lua/autorun/tfa_vox_loader.lua:4


[[TFA-VOX\] Sonic The Hedgehog (2010-Present)\] lua/tfa_vox/packs/tfa_vox_sonic_2010_present.lua:83: '}' expected near 'player'

1. v - lua/tfa_vox/framework/tfa_vox_packs.lua:120

2. unknown - lua/includes/modules/hook.lua:96


[[TFA-VOX\] Sonic The Hedgehog (2010-Present)\] lua/tfa_vox/packs/tfa_vox_sonic_2010_present.lua:83: '}' expected near 'player'

1. TFAVOX_Packs_Initialize - lua/tfa_vox/framework/tfa_vox_packs.lua:123

2. unknown - lua/tfa_vox/framework/tfa_vox_packs.lua:184

3. include - [C\]:-1

4. unknown - lua/autorun/tfa_vox_loader.lua:4


[[TFA-VOX\] Sonic The Hedgehog (2010-Present)\] lua/tfa_vox/packs/tfa_vox_sonic_2010_present.lua:83: '}' expected near 'player'

1. v - lua/tfa_vox/framework/tfa_vox_packs.lua:123

2. unknown - lua/includes/modules/hook.lua:96


[[TFA-VOX\] Sonic The Hedgehog (2010-Present)\] lua/tfa_vox/packs/tfa_vox_sonic_2010_present.lua:83: '}' expected near 'player'

1. TFAVOX_Packs_Initialize - lua/tfa_vox/framework/tfa_vox_packs.lua:120

2. tfa_reload - lua/autorun/lf_playermodel_selector.lua:124

3. func - lua/autorun/lf_playermodel_selector.lua:149

4. unknown - lua/includes/extensions/net.lua:38

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