Lua - Reddit – Telegram
Lua - Reddit
31 subscribers
281 photos
31 videos
4.26K links
News and discussion for the Lua programming language.

Subreddit: https://www.reddit.com/r/lua

Powered by : @r_channels & @reddit2telegram
Download Telegram
Using continuation functions as normal functions possible?

I have often the case where I want to loop and within that loop call a lua function or have to yield, but yieldable with continuation.
For that I have to provide a continuation function which only functions as trampoline to call the normal function again.

int foo(luaState*);
int foo
continue(luaState* L, int, luaKContext) {
foo(L);
}
int foo(luaState* L) {
while (true) {
/* do things */
lua
yield(L, 0, NULL, &foocontinue);
}
}
int main() {
// ...
lua
pushcfunction(L, &foo);
// ...
}

Because I have to persist the runtime, I'm using Eris, I now also have to add the continuation function to the persistency table.

I would love to remove that boilerplate by simply doing something like this:

int foo(luaState* L, int, luaKContext) {
while (true) {
/ do things /
luayield(L, 0, NULL, &foo);
}
}
int main() {
// ...
lua
pushcfunction(L, &foo);
// ...
}

Using reinterpret cast that seems to work just fine but idk if that is really stable and doesnt cause undefined behaviour.
So, is this allowed or not?

https://redd.it/1jo284c
@r_lua
Good resources on Lua that also teach programming fundamentals?

I'd like to believe I know Lua well enough, having used it a lot for game modding. However there's a lot of people who come to our community trying to make mods with zero knowledge of programming, and trying to help those people gets frustrating for everyone involved.

What resources are there that teach Lua while also explaining basic concepts (variables, conditionals, loops, etc.)? First few tutorials I could find seem to be made for people who already know programming and just need a crash course on specifics of the language...

https://redd.it/1jo4ihc
@r_lua
Termfx make fails with error lua.h: No such file or directory

What it says on the tincan. Attempting to build Termfx without Luarocks (because luarocks has caused nothing but pain and suffering for me) and I'm not able to make it successfully as it doesn't seem to be able to find the C headers.

I think this boils down to me not specifying where the lua.h file is, but I don't know how I can do that. Thanks for any help

https://redd.it/1jo7trj
@r_lua
Accidently deleted Ghub lua noscript command and now cant remember.

There was a lua file located on my computer on D: , a noscript was running it without copying everything to GHUB,it was someting like D: ..... Test.lua, i accidently deleted it and cant remember now would you guys help me?

https://redd.it/1jp2z0m
@r_lua
Obfuscated lua file

Hey. I have a lua file that is in my fivem server, I need to edit a few things in the file
Is there a way to deobfuscate the file through my server key?
I bought the file legally

https://redd.it/1jp8yq8
@r_lua
What special Lua tutorial would be useful?

Hello I make YouTube tutorials. I made a general “Learn Lua” tutorial but I would like to make specific tutorials. I was thinking of teach concepts like strings (and its functions) and metatables. Are there any tutorials that would be useful please let me know?

https://redd.it/1jq4kyd
@r_lua
RE Clone?

So I would like to make what is essentially a classic RE Clone, survival horror genre, tank controls, fixed camera angles, pre rendered backgrounds, etc. Would Lua be a good platform for that?

https://redd.it/1jquivi
@r_lua
funcional microphone help

Hi, I need help making or finding a code to make a functional microphone for voice chat in Roblox. If anyone has a noscript that might work, please share it with me and if you can, explain to me how to use it, hehe (sorry if I asked for too much).

https://redd.it/1jqvlcq
@r_lua
What’s the best way to learn lua?

I’m brand new to lua and I’ve wanted to learn for years now specifically to noscript roblox games but also just to use for my own fun. Which was making me want to ask what applications, websites, videos are useful that could be recommended for me to learn?

https://redd.it/1jqvcl5
@r_lua
Help me with noscript for GHub.

Hello, im just trying to make noscript that clicks certain points on the screen. Problem is, running noscript doesn't use right mouse button or doesnt use it at all. Also i need to run it, untill certain button is pressed. could you help me with that?

function OnEvent(event, arg)

if event == "PROFILE_ACTIVATED" then

EnablePrimaryMouseButtonEvents(true)

elseif event == "MOUSE_BUTTON_PRESSED" and arg == 3 then

if IsKeyLockOn("capslock") then

repeat

MoveMouseTo(39785,17614)

PressMouseButton(2)

Sleep(10)

ReleaseMouseButton(2)

Sleep(2000)

MoveMouseTo(37258, 17492)

PressMouseButton(2)

Sleep(5)

ReleaseMouseButton(2)

Sleep(1000)

MoveMouseTo(28072, 34741)

PressMouseButton(2)

Sleep(10)

ReleaseMouseButton(2)

Sleep(1000)

MoveMouseTo(28550, 41665)

PressMouseButton(2)

Sleep(10)

ReleaseMouseButton(2)

Sleep(1000)

if not IsMouseButtonPressed(4) then break end

MoveMouseRelative(0,4)

Sleep(10)

PressMouseButton(2)

until not IsMouseButtonPressed(4) -- 4 = "Back"

end

end

end



https://redd.it/1jrjhqp
@r_lua
Luarocks Error: Attempted to index a nil value (field 'LUA_BINDIR')

Whenever I try to do anything with luarocks (ANYTHING) I get a litle pop up with this error:

\[string "src/luarocks/core/cfg.lua"\]:824: attempt to index a nil value (field 'LUA BINDIR')

stack traceback:

\[string "src/luarocks/core/cfg.lua"\]:824: in function 'luarocks.core.cfg.init

\[string "src/luarocks/loader.lua"\]:21: in main chunk \[C\]: in function 'require'

\[string "luarocks"\]:5: in main chunk \[C\]: in ?

I have LuaJIT installed as well as LOVE, which I am trying to get luarocks to work with. I have my paths correctly added, and everything SHOULD work, but it doesn't. I cant do any cmd commands with luarocks because everything returns the same error. I can't find anything online.


(Edit: When I say I was trying to use LOVE with luarocks, I'm not trying to install LOVE, I'm trying to install packages so I can used them WITH love, just FYI.)

https://redd.it/1jrv0tp
@r_lua
Just need some help with keeping letters with ASCII numbers just being singular letters

(This LUA code is specifically for the game Stormworks)
After a few hours, I learned how to decode ASCII letters (ex: 1008403 makes 84 as T and 03 as the 3rd letter), just need some help on saving those letters without them disappearing under a tick since for example 84 rapidly changes into a different number like for example again 65 (which makes A) for a new letter since the name becomes ASCII and only back to single letter(84 becomes 65 without actually adding a new letter because it gets immediately replaced) and 03 rapidly changed as well since it becomes 1st 2nd 3rd letter of the word etc(though the last 2 digits (ex:03 again) helps place one letter to another position like placing to a few pixels to somewhere of a monitor). (apologies if it's confusing since It's a bit hard to explain this).

BTW here's a view of my LUA code to help with it:
function onTick() AR1 =input.getNumber(1) ST1 = string.format("%00d", math.floor(AR1)) V1 = string.char(ST1 % 1000) AR2 =input.getNumber(2) end function onDraw() screen.drawText(32+(AR2*5), 32, V1) end

I'd really appreciate any help since chatGPT gave me a headache without doing anything useful to the code except making it worse.

https://redd.it/1jsbjop
@r_lua
luarocks doesn't work and I don't know why (noobie)

https://preview.redd.it/tpqg39ft23te1.png?width=681&format=png&auto=webp&s=151d13b365db9849f860f4e3c754a634762dac10

welp, installed it with the bat file, added everything to paths, the wiki says to just "luarocks install [rock\]" but uh not quite, what does build type imply?

https://redd.it/1jse28b
@r_lua
Luamacros question: Original input still being sent

I know it's not exactly Lua but the hidmacros forum is dead so this is the only place to ask.

Long story short, I have a gamepad with extra buttons bound to the numpad. I have a Luamacros noscript that catches the input from this controller (believing it to be a keyboard) and outputs F13-F22. However, it still sends the original numpad button too, so it actually reads as numpad1 + F13 and whatnot. I have no idea how to fix this, I've tried running as admin but it won't work. Any idea how to fix this?

https://redd.it/1jso6n4
@r_lua
Hello, LUA members, I need help from you experts to make sure this code will work (I'm a noob at coding)

So, I'm making a noscript to make it so every 10 seconds 300 unanchored parts are added (to lag the game), and after 60 seconds the noscript will stop, will this work?:

game.Workspace:WaitForChild("Treehouse").CanCollide = true --Treehouse is a model.
game.Workspace:WaitForChild("Tree").CanCollide = true --Tree is also a model.


local baseplate = game.Workspace:WaitForChild("Baseplate")

local function createParts()
for i = 1, 300 do

local part = Instance.new("Part")
part.Size = Vector3.new(1, 1, 1) -- Set part size
part.Position = baseplate.Position - Vector3.new(0, 5, 0) + Vector3.new(math.random(-50, 50), 0, math.random(-50, 50, 50)
part.Anchored = false
part.Parent = game.Workspace
end
end

local startTime = tick()
local endTime = startTime + 60

while tick() < endTime do
wait(10)

createParts()
end

Sorry for bothering y'all if I did.

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