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
Problems With Sol and the Lua Library

Hello! I'm currently setting up an SDL project and wanted to use Lua to some extent. However, I'm having issues including Sol in the project. I haven't had problems with any of the other libraries I'm using, just Sol-Lua specifically. I've included the appropriate Include and Library paths. If you have any experience with this library, could you help me figure out what I could be doing wrong? Any help would be greatly appreciated.

https://preview.redd.it/6xccupiqtkbe1.jpg?width=690&format=pjpg&auto=webp&s=bfb4ed9972478dff87eff0d937812cc1ae960c46

https://preview.redd.it/ob7bspiqtkbe1.jpg?width=382&format=pjpg&auto=webp&s=de93af5063745d80ce441824d3687edce65caa4f

https://preview.redd.it/gaj84riqtkbe1.jpg?width=387&format=pjpg&auto=webp&s=41207f7d64fa33ba55d2540ae8704f9c31ae5441

https://preview.redd.it/nhvz1riqtkbe1.jpg?width=470&format=pjpg&auto=webp&s=4854db036f9fc989fb7b585671eec7f79ae72ff6

https://redd.it/1hvuitn
@r_lua
Im trying to make my dude teleport forward a few seconds after pressing one

me my brother a friend of mine and one of my friend's friends are making a roblox battlegrounds game. even tho my friend and his friend are the ones supposed to be coding, they're not really helping fix the move. basically the dude goes into a running stance, then flashes forward and kicks. however, right now all he does is run forward. ples tell me how im supposed to do it

https://redd.it/1hw3elt
@r_lua
Announcing Astra - LuaJIT webserver built on top of Rust

Hey everyone! Hope the new year has been chill so far.

I am very happy to announce Astra (https://astra.arkforge.net), a small webserver built on top of Rust + Axum for LuaJIT (Lua PUC versions coming soon). The goal is to have a fault-tolerant, fast, memory safe, and auto scaling web server while at the same time being insanely easy to use and extend. This project is mainly used so far within our company for some products and sees development wherever we find need for.

Some examples from the README:

-- Routes are defined through these route functions
-- route functions need a path and a callback
Astra.get("/", function()
-- they may have a return too (optional)
return "hello from default Astra instance!"
end)

-- Local and global variables can be mutated at any
-- time as the callbacks are ran on runtime.
local counter = 0
Astra.get("/count", function()
counter = counter + 1
-- and also can return JSON
return { countervalue = counter }
end)

-- The callback function offers requests and responses
-- arguments which can be used to consume incoming data
-- and shape outgoinging structure
Astra.get("/", function(req, res)
-- set header code
res:set
statuscode(300)
-- set headers
res:set
header("header-key", "header-value")

-- read the request body
print(req:body():text())

return "Responding with Code 300 cuz why not"
end)

There are also a lot of utilities provided as well, such as table schema validation (as an alternative to having typed tables), HTTP client, PostgreSQL driver, async tasks, markup language parsing such as JSON, ... and with more to come in the future such as templating. There are also some functionality missing as of yet, such as websockets, which will come with time.

This webserver is packaged as a single binary that you can just download on server of your local machine (prebuilt binary releases for windows and linux x64 are available) and can generally assume what works locally will work on the cloud as well since they both will use the same binary and instructions. The binary also packages the bundled lua code that includes some utilities and the Astra's own type definitions for help with intellisense in some cases.

Enjoy!

https://redd.it/1hwfmz5
@r_lua
Good practices - (type|nil) vs (type) passed in an if statement

Hello, which of below cases is a good practice in lua?

case 1:

local function foo(arg, bool)
bar(arg)
-- passing bool: boolean|nil
if bool then baz() end
end

case 2:

local function foo(arg, bool)
bar(arg)
bool = (bool ~= nil and bool)
-- passing bool: boolean
if bool then baz() end
end



https://redd.it/1hwkf0f
@r_lua
MPV Lua Script to cycle through specific audio and subs of a video

Here is an example:

A video have 5 audio in it (English, Japanese, Spanish, German, French) and it also have 5 subs in it (English, Japanese, Spanish, German, French).

With the above example, how can I cycle to specific audio and subs while skipping the other ones? I'm only interested in English, Japanese and Spanish, which means I don't want to cycle through German and French and I want to get rid of those languages when I'm cycling with the hotkey, how can I do this? is there a Lua noscript that can make this happen?

Note: It needs to be able to cycle the subnoscript inside the "Subs" folder as well as long as the subnoscript has the same name as the video.

https://redd.it/1hwoy6t
@r_lua
MPV.net (media player) On Screen Controller Lua Script help

I have this noscript that hides the OSC in fullscreen but it's always visible when I exit fullscreen:

-- Keeps the OSC visible in windowed mode and hides it in fullscreen
mp.observeproperty("fullscreen", "bool", function(, isfullscreen)
if is
fullscreen then
-- Hide the OSC in fullscreen mode
mp.command("noscript-message osc-visibility auto")
else
-- Always show the OSC in windowed mode
mp.command("noscript-message osc-visibility always")
end
end)

The noscript works fine but there is a problem, when I enter fullscreen I get an on-screen text saying "OSC visibility: Auto", and when I exit fullscreen it says "OSC visibility: Always", how can I modify the above noscript to remove those 2 annoying on-screen text messages?

https://redd.it/1hwosxn
@r_lua
Is there a Lua noscript to have the Audio/Sub icon show a mini-menu?

I'm using MPV.net, is there a way to make the Audio/Sub icon of the player show a menu with the available audio and subnoscripts? With the default behavior, clicking these icons cycles through them which is a pain because if a video has 10 audio or subnoscripts it will cycle through each one of them so it's counter-productive for me.

Instead of the default behavior, I want to click on it, open a mini-menu and select my specific audio or subnoscripts and not cycle through them. Is there a Lua noscript that can make this happen?

https://preview.redd.it/tqlh8crgwtbe1.jpg?width=932&format=pjpg&auto=webp&s=9fefec81016d993f9a58f04d09f396cfccedb838



https://redd.it/1hwtuxi
@r_lua
I'm trying to learn Roblox lua
https://redd.it/1hwu30o
@r_lua
Make an object face the camera (roblox studio)

I'm pretty new to coding Lua, so I have like no clue how to do anything. I'm trying to get an object to face towards the camera at all times, and I've gone into countless forums and things where people asked a similar question, but I can't find anything that actually works or even has an effect on the object for that matter. Any Suggestions?

I would also like to know somewhere I can get lessons on coding with Lua.

https://redd.it/1hwt60i
@r_lua
Is chatgpt a valuable resource to help with learning with the basics, or a resource to avoid?

been trying to learn lua specificly off and on for the past few years. finally commiting to getting a functional and practical level of understanding and want to know if that a is a viable resource or if I should stick to ONLY other sources.

https://redd.it/1hwssbt
@r_lua
Language aware diff for Lua with integration into VS Code and GitHub

Hi there,

I am working on SemanticDiff, a programming language aware diff that hides style-only changes, detects moved code and refactorings. We just added support for Lua and would like to know what you think!

SemanticDiff parses the contents of Lua files to distinguish between relevant and irrelevant changes. This way it can, for example, ignore whitespace outside of strings or how a string literal is written (brackets vs. quotes). The idea is to generate a diff with less noise:

https://preview.redd.it/g9728xu9dzbe1.png?width=901&format=png&auto=webp&s=451f316b29a8d18a173cead431843a631d4d3d97

The VS Code extension is completely free and the GitHub App is free as well if used with public repositories or private repositories that have 3 or less contributors. If this sounds interesting, you can read the release blog post to learn more.

Looking forward to your feedback.

https://redd.it/1hxedws
@r_lua
ı need help disconeccting remote serverrr

right now the code looks liek this:

game.ReplicatedStorage.shake.OnClientEvent:Connect(function()

local Camera = game.Workspace.CurrentCamera

local Seed = math.random()

local X = 0

local Z = 0

game:GetService("RunService").RenderStepped:Connect(function()

Camera.CFrame = Camera.CFrame * CFrame.Angles(math.noise(Seed, X * 0.35, Z * 0.35) * 0.02, math.noise(X * 0.35, Seed, Z * 0.35) * 0.02, 0)

X = X + 0.4

Z = Z + 0.4

end)

end)

please help em its an emergency

https://redd.it/1hxhq0n
@r_lua
ZeroBrane Autocomplete Function?

Hi guys,

I've recently tried some other ide's but zerobrane just works great with lua & love2d.

However atom and vscode both have this thing where you type fun and it autocreates a function putting your line at the noscript, tab to switch to args and tab to switch to body.

Can someone help/direct/guide me to getting this on zerobrane?

https://redd.it/1hxmbh2
@r_lua
Lua Language Server support for my 2D game framework

Hi everyone,

I wanted to share something I’ve been working on over the past few weeks. I’ve improved the Lua development workflow for my open-source 2D game framework, nCine, and put together a video to demonstrate it.

The updated workflow now includes:

- Autocomplete
- Type checking
- Full API documentation
- Debugger support

These features are made possible thanks to the Lua Language Server and the Local Lua Debugger, and they make noscripting a lot more efficient and enjoyable.

Here’s the video if you’d like to check it out:
🎥 https://www.youtube.com/watch?v=vyXqnrW5_5Y

If you’re interested, there’s more information in the video denoscription and on the project’s website: https://ncine.github.io/.

If you’ve used the Lua Language Server with other game frameworks like LÖVE, Solarus, or Solar2D, I’d love to hear your thoughts. Does this workflow feel on par with what you’ve experienced?

https://redd.it/1hy5qnj
@r_lua
Help with lua returning a string for conky

Hello, i am looking to get some help with lua. I am trying to create a noscript to get and return weather data for conky. It mostly works as text until i tried to get it to display images. I have all the images it needs, but when i try to get it to load the images in conky instead of the image i jsut get the conky image command as text

This is the string i am using



-- Return the image path

return string.format("Location: %s\nTemperature: %d°C\nCondition: %s\nHumidity: %d%%\nWind Speed: %.1f m/s\n${image \"%s/.conky/lua/images/%s.png\"}",

city, temp, condition, humidity, wind_speed, os.getenv("HOME"), icon_code)

It displays as this

https://ibb.co/XpmRs9j

Can anyone help me figure out what's wrong ?

Thanks!



https://redd.it/1hy7ttj
@r_lua
2d IDE for lua game dev that isn't pico-8?

Hey y'all, going through a bit of a confusing time rn as far as programming goes, was set on Lua but then switched to python, then to C, then to Go, then to common lisp, now back on Lua again. I was "learning lua" for a few months but made like zero progress because I didn't really do anything, so I want to change that this time. Anyway, back to what I was saying and sorry for the mini-rant lol, do any of y'all have recommendations for 2D IDE's/Engines for Lua game development that aren't pico-8? Also for anyone wondering why not pico-8, I has no moneys and also I don't like the constraints (I know why they're there, just not for me). If not I'll just learn Löve2d. Thanks!

https://redd.it/1hzaqbz
@r_lua
"Programming in Lua" Journey

A while back I decided that I want to add lua binding to the project I'm working on (ceph). I'm mainly a C++ developer, and did not have any real experience with lua (except helping my kid with some roblox stuff...).

Initially, I picked lua since other projects in similar domains use it (nginx, haproxy, redis, etc.), but as I went on with my work I really fell in love with the language :-)

Currently, I have most of the bindings implemented on the Object Gateway of Ceph. But,I also figured out my knowledge of the language itself is very limited...

To try and fix that, I bought the "Programming in Lua" book and started to read through it and do the exercises (reading is pretty useless without the exercises). So far, I finished "Part I" (chapters 1 - 8), and documented in this repo: https://github.com/yuvalif/PIL

It has been great fun, but could be even better if done together with others. So, if anyone has also gone through these exercises, or want to give me some feedback, new ideas or want to tag along in this journey, it would be wonderful!

(I'll try to post regularly as I chew through the book)

https://redd.it/1hzslfk
@r_lua
Problems while installing LÖVR on EndeavourOS linux.

Hi, recently I tried to install LÖVR by compiling it from source. I cloned the repo and ran

$ mkdir build

$ cd build

$ cmake ..

$ cmake --build .

Unfortunately, docs don't list what to do after this and probably assume some level of CMake profficiency:
[https://lovr.org/docs/Compiling#linux](https://lovr.org/docs/Compiling#linux)

They say how to run LÖVR with VR, but that's not what I want to do right now.

Now, if i run `lovr` file from bin subdirectory, I get this error:

lovr: /usr/src/debug/glfw/glfw-3.4/src/window.c:868: glfwGetWindowAttrib: Assertion `window != NULL' failed.
Aborted (core dumped)

If I run `sudo make install .` I get different error:

CMake Error at luajit/src/cmake_install.cmake:81 (file):
file INSTALL cannot find
"/home/user1/dev/lovr/first_touch/build/luajit/src/luajit": No such file
or directory.
Call Stack (most recent call first):
luajit/cmake_install.cmake:47 (include)
cmake_install.cmake:48 (include)

I do not really use CMake that often and am not fluent in compiling software from source.

What have I done wrong? And what should I do now?

Thanks in advance.

https://redd.it/1i0bzno
@r_lua
Can a LUA noscript be used to replace a file that is within a ZIP file?

I am very new to this so I apologize if this is a stupid question.

I'm currently designing a Reaper Theme that will have it's own theme adjuster (the adjuster is the lua noscript), and I'm trying to plan ahead a bit and figure out what I should or should not be investing time into.

Something I wanted for the theme is the ability to swap out theme images using the noscript, similar to this noscript (it's called the Theme Assembler which is used in conjunction with the Theme Assembler Theme).

Normally, a theme and all it's files are zipped within a .ReaperThemeZip file (but it doesn't need to be). In order for the Theme Assembler noscript to work however the Theme Assembler theme must be unpacked.

Want I want to know is if it's possible to accomplish the same thing if the theme was in its zipped state with the .ReaperThemeZip. Basically to use a LUA noscript to drop in and replace images within the .ReaperThemeZip.

https://redd.it/1i0hz0y
@r_lua
Can anyone tell me what this code does?

I found it in a YouTube video and I was just curious.

`loadstring("function IllIlllIllIlllIlllIlllIll(IllIlllIllIllIll) if (IllIlllIllIllIll==(((((919 + 636)-636)*3147)/3147)+919)) then return not true end if (IllIlllIllIllIll==(((((968 + 670)-670)*3315)/3315)+968)) then return not false end end; local IIllllIIllll = (7*3-9/9+3*2/0+3*3);local IIlllIIlllIIlllIIlllII = (3*4-7/7+6*4/3+9*9); function IllIIIIllIIIIIl(IIllllIIllll) function IIllllIIllll(IIllllIIllll) function IIllllIIllll(IllIllIllIllI) end end end;IllIIIIllIIIIIl(900283);function IllIlllIllIlllIlllIlllIllIlllIIIlll(IIlllIIlllIIlllIIlllII) function IIllllIIllll(IllIllIllIllI) local IIlllIIlllIIlllIIlllII = (9*0-7/5+3*1/3+8*2) end end;IllIlllIllIlllIlllIlllIllIlllIIIlll(9083);local IllIIllIIllIII = loadstring;local IlIlIlIlIlIlIlIlII = "local Fluent = loadstring(game:HttpGet("https://github.com/dawid-noscripts/Fluent/releases/latest/download/main.lua"))() local UserInputService = game:GetService("UserInputService") local LocalPlayer = game:GetService("Players").LocalPlayer local MarketplaceService = game:GetService("MarketplaceService") local GamePassID = 1029112746 local Positions = { ["Dock"] = Vector3.new(445.53, 40.24, 392.25), ["Sweet Shop"] = Vector3.new(732.36, 156.41, -934.99), ["Gift-Making Place"] = Vector3.new(919.32, 235.89, -1137.43), ["Church"] = Vector3.new(998.83, 231.93, -941.85), } local PositionButtons = {} local function DisplayMessage(message, color) Fluent:Notify({ Title = "Access Denied", Content = message, Duration = 5, Image = "error", Color = color }) end local function CheckAccess(player) local success, hasPass = pcall(function() return MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamePassID) end) if success and hasPass then return true else return false end end if not CheckAccess(LocalPlayer) then DisplayMessage("You do not have access to this noscript.\nPlease buy the game pass.\nContact @notyashlol on Discord for help.", Color3.fromRGB(255, 0, 0)) return else local welcomeMessage = "Welcome to Manjiro Script Hub!" if LocalPlayer.Name == "yashgamer2233" then welcomeMessage = "Hello, Master! Access granted." elseif LocalPlayer.Name == "Karina_Siwa2" then welcomeMessage = "Hello, Mistress! Access granted." end DisplayMessage(welcomeMessage, Color3.fromRGB(0, 255, 0)) end local Window = Fluent:CreateWindow({ Title = "Manjiro Script Hub", SubTitle = "Save, Load, and Manage Positions with Ease!", Theme = "Dark", TabWidth = 160, Size = UDim2.fromOffset(580, 460), Acrylic = true, }) local Tabs = { ManagePositions = Window:AddTab({ Title = "Manage Positions", Icon = "save" }) } local function RefreshPositionButtons(section) for _, button in ipairs(PositionButtons) do button:Destroy() end PositionButtons = {} for name, position in pairs(Positions) do local button = section:AddButton({ Title = "Load: " .. name, Callback = function() if LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("HumanoidRootPart") then LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(position) Fluent:Notify({ Title = "Success", Content = "Position loaded: " .. name, Duration = 5, Image = "check" }) else Fluent:Notify({ Title = "Error", Content = "Character or HumanoidRootPart not found.", Duration = 5, Image = "x" }) end end }) table.insert(PositionButtons, button) end end do local ManageSection = Tabs.ManagePositions:AddSection("Position Management") Tabs.ManagePositions:AddInput("PositionName", { Title = "Position Name", Default = "", Placeholder = "Enter a position name...", Callback = function(value) positionName = value end }) Tabs.ManagePositions:AddButton({ Title = "Save Position", Callback = function() if not positionName or positionName == "" then Fluent:Notify({ Title = "Error", Content = "Please enter a valid position name.", Duration = 5, Image = "x" }) return end local character = LocalPlayer.Character if character and character:FindFirstChild("HumanoidRootPart") then Positions[positionName] = character.HumanoidRootPart.Position SavePositionsToFile() Fluent:Notify({ Title = "Success",