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
Garry's Mod default chat box not showing up anymore

A while ago I started a game mode for fun and recently got back into making it.

I made a chat box using the Garry's mod wiki tutorial. I came back and wanted to remake it so I deleted my chat.lua file and all trace of that chat box inside the game mode folder, for some reason the default Garry's mod chat box doesn't show up anymore.

I've tried making a new dedicated server, tried reinstalling gmod (including deleting the directory), and tried commenting out other vgui elements. At last I am stumped and have no idea what is going on.

Any help / idea's is appreciated.


Edit: I should mention i would post in r/GLua but that community seems pretty dead.

https://redd.it/1fzjx89
@r_lua
How can I get this noscript so it repeats until toggled off?

I will paste my current lua noscript below. I am doing this Logitech Ghub. This is currently a test. In this test I click the button on my mouse and toggles the noscript on which then makes 10 mouse movements and then stops. I want this to constantly repeat until I click the same button to toggle it off after it completes the current cycle. I am not a coder and have only been using Google/Youtube/AI so any assistance is appreciated.

-- Declare a global variable for toggling the noscript
local toggle = false

-- Define a key to toggle the noscript on/off (you can set any key, e.g., 5 for mouse button 5)
local toggleKey = 5  -- Change this to the button or key you want to use

-- Function to handle mouse movements
function moveMouse()
    OutputLogMessage("moveMouse started\n")
   
    -- Perform the mouse movements step by step, checking the toggle after each step
    if toggle then
        OutputLogMessage("Moving to (4567, 22267)\n")
        MoveMouseTo(4567, 22267)
        Sleep(1000)
    end

    if toggle then
        OutputLogMessage("Moving to (47667, 22367)\n")
        MoveMouseTo(47667, 22367)
        Sleep(1000)
    end

    if toggle then
        OutputLogMessage("Moving to (49667, 22367)\n")
        MoveMouseTo(49667, 22367)
        Sleep(1000)
    end

    if toggle then
        OutputLogMessage("Moving to (49667, 25367)\n")
        MoveMouseTo(49667, 25367)
        Sleep(1000)
    end

    if toggle then
        OutputLogMessage("Moving to (49667, 45067)\n")
        MoveMouseTo(49667, 45067)
        Sleep(1000)
    end

    OutputLogMessage("moveMouse completed\n")
end

-- This function runs when the toggle key is pressed
function OnEvent(event, arg)
    if event == "MOUSEBUTTONPRESSED" and arg == toggleKey then
        toggle = not toggle  -- Switch the toggle value (on/off)
        OutputLogMessage("Toggle button pressed. New toggle state: %s\n", tostring(toggle))
       
        if toggle then
            OutputLogMessage("Script Started\n")
            moveMouse()  -- Call the function to move the mouse when toggled on
        else
            OutputLogMessage("Script Stopped\n")
        end
    end
end







https://redd.it/1fzol4l
@r_lua
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