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
Can't seem to call wrefresh or wborder in lcurses

I'm trying to use lcurses in lua5.3. Creating the window is fine but any attempt to call eg curses.wrefresh(new_win) so it displays fails as calling a nil value. Same with calling new_win:wrefresh(). Frankly the token example in lcurses on github is woefully inadequate.

local function main ()
local stdscr = curses.initscr ()

curses.cbreak ()
curses.echo (false)
curses.nl (false)

stdscr:clear ()

newwin = curses.newwin(10,30,5,5)
new
win:box(0,0)
newwin:mvaddstr(1, 3, "Box Title")
curses.wrefresh(new
win) - fails - nil value
newwin:wrefresh() - also fails nil value


stdscr:refresh ()

local c = stdscr:getch ()
if c < 256 then c = string.char (c) end

curses.endwin ()
end


The odd thing is I can call new\
win:box(0,0) but can't call new_win:wborder(0,0,0,0,0,0) - similarly a nil value - which should be identical


https://redd.it/1j9ybe2
@r_lua
Very specific Lua question: is there a Lua equivalent to "pop"ing an element of an "array"?

Context: New to Lua, trying to write a PI controller (as in PID) to run on a Pixhawk 4 flight controller. The final code needs to be small and efficient so it can be run as fast as possible.

In a different language, my approach would be to have an array of fixed size, holding the error at each of the past n steps, and a variable that holds the sum total of that array to act as the integral for the I controller. On every step, I'd pop the first array element to subtract it from the variable, then add my new step error to the array and total, then update the output according to the new total.

But I've been trying to read documentation and it seems like the table.remove() is inefficient if used like this?

My backup plan would be to just have a looping index variable and replace that array element instead of "pop"ing, but I want to know if there's a more effective way to do this.



https://redd.it/1jadn5y
@r_lua
.lua noscripts MPV

I have it in two locations which I've found both online. i need to run .lua noscripts on MPV using the noscript :https://github.com/gthreepw00d/mpv-iptv



both my locations for noscripts currently are :



C:\\Program Files\\mpv\\portable_config\\noscripts



C:\\Users\\USERNAME\\AppData\\Roaming\\mpv\\Scripts



These are the locations i have seen suggested online:



in my noscripts folders are:

https://github.com/mpv-player/mpv/blob/master/etc/mpv.conf

https://github.com/mpv-player/mpv/blob/master/etc/input.conf

https://github.com/gthreepw00d/mpv-iptv



How do I get .lua noscripts to run on MPV T.T



https://redd.it/1japyt4
@r_lua
I want to create a website using HTML, CSS, & Lua; but Frameworks don't work for me apparently.

I want to create my own website using HTML, CSS, & Lua; & so I tried to install a frame-work, (Lapis); but it isn't working, does ANYBODY here know how to install Lapis for Windows 11? Because it just seems physically impossible for me, & is it even possible to do it without a frame-work?

https://redd.it/1jar7uk
@r_lua
How to view/edit Balatro source code?

Hello all!

I am fairly new to programming in general but I've been putting a lot of time and effort into learning Lua. I started with aspirations to create a mod for Balatro, and am very confident in the basics of the language. However the next roadblock I've hit is how to actually view the source code for Balatro so that I can read through it and gain an understanding of how the engine and functions work. Is there a specific software I need to use to open these files, and would it be the same software that I would use to code and develop my own mod?

https://redd.it/1jauv1m
@r_lua
Alguem pode me ajudar, quando entro em algum servidor no Fivem e puxo celular ele não abre e aparece o seguinte erro

https://preview.redd.it/1orv2a7fqloe1.png?width=1920&format=png&auto=webp&s=b2325bd81ece3cb9aacbaf51f8db5db46bb96f88

SCRIPT ERROR: u/inventory/client-side/core.lua:52: No such export open in resource smartphone

O código com erro esta destacado em vermelho na ultima linha, na imagem




https://redd.it/1jaxu5l
@r_lua
help on noscript

hi i need help on making door that when some one oppens and car drops on u and kill you i would really appreciate if some one would tell me how to do thanks🙏

https://redd.it/1jbg8yl
@r_lua
PsychEngineLua: Cancel initial strum notes animation

Does anyone know if it's possible to cancel the animation at the beginning of the song, where the strum line notes are visible? It can be done in hnoscript

https://redd.it/1jbvt97
@r_lua
Sol + Enet

I want to call functions in the Lua state when a packet is received etc., but enet is currently on a separate thread to not hang the main thread. However, I have noticed a lot of memory problems that come from this. I've tried using mutex but nothing has been alleviated. Any guidance or perhaps different networking libraries I should consider?

https://redd.it/1jcd83l
@r_lua
Help me, Fivem server programmers.Problem on, Core.Lua

Can you help me? I'm having an error opening the phone on all servers in Fivem.
The error and this.
inventory/client-side/core.lua:52: No such export open in resource smartphone

https://redd.it/1jckfym
@r_lua
How would I go about making walls give momentum

I'm currently making a game where movement and momentum are large parts of it, how would I go about making a momentum retaining wall system and or wall run system

https://redd.it/1jd2a34
@r_lua
FishBots - a tiny Lua coding game
https://redd.it/1jdh061
@r_lua
My "Bullet" doesn't deal any damage on collision.

So im trying to make a gun/blunderbuss in roblox and everything works just fine apart from the damage, i've tried a lot of things to fix it but nothing worked, someone help me Please.


This is the Script:

`local tool = noscript.Parent`

`local bulletsFolder = noscript.Parent:FindFirstChild("Bullets")`



`function createBullet(bulletPosition)`

`local Bullet = Instance.New("Part", bulletsFolder)`

`Bullet.CFrame = CFrame.new(bulletPosition)`

[`Bullet.Name`](http://Bullet.Name) `= "Bullet"`

`Bullet.Size = Vector3.new(0.1,0.1,0.1)`

`Bullet.BrickColor = BrickColor.new("Black metallic")`

`Bullet.Shape = Enum.PartType.Ball`

`Bullet.CanCollide = true`

`Bullet.Transparency = 0`

`Bullet.BottomSurface = Enum.SurfaceType.Smooth`

`Bullet.TopSurface = Enum.SurfaceType.Smooth`

`Bullet.Anchored = true`



`game.Debris:AddItem(Bullet, 10)`





`end`



`-- raycasting`

`noscript.Parent.Shoot.OnServerEvent:Connect(function(player, mousePosition)`

`local raycastParams = RaycastParams.new()`

`raycastParams.FilterDescendantsInstances = {player.Character}`

`raycastParams.FilterType = Enum.RaycastFilterType.Exclude`



`local raycastResult = workspace:Raycast(tool.Handle.Barrel.Position,(mousePosition - tool.Handle.Barrel.Position) * 300, raycastParams)`



`if raycastResult.Position then`

`createBullet(raycastResult.Position)`

`end`



`if raycastResult then`

`local raycastInstance = raycastResult.Instance`

`local model = raycastInstance:FindFirstAncestorOfClass("Model")`



`if model then`

`if model:FindFirstChild("Humanoid") then`

`if` [`raycastInstance.Name`](http://raycastInstance.Name) `=="Head" then`

`model:FindFirstChild("Humanoid"):TakeDamage(40)`

`else`

`model:FindFirstChild("Humanoid"):TakeDamage(20)`

`end`

`end`

`end`

`end`



`end)`

and this is the Local Script:

`local userInputService = game:GetService("UserInputService") --UIS`



`local player = game.Players.LocalPlayer --player`

`local mouse = player:GetMouse() -- mouse`



`local tool = noscript.Parent`

`local debounce = false`



`local ammo = 1`

`local MaxAmmo = 8`

`local reloading = false`

`local isEquipped = false`



`--Reloading`

`local function reload()`

`if reloading == false and isEquipped and MaxAmmo > 0 then`

`reloading = true`

`tool.Sounds["Gun Reload"]:Play()`

`task.wait(1.987)`

`ammo = 1`

`MaxAmmo -= 1`

`player.PlayerGui.AmmoGui.Frame.TextLabel.Text = "Ammo: "..ammo.."/"..MaxAmmo`

`reloading = false`

`end`

`end`



`--Bullet`

`local function createBullet()`

`local Bullet = Instance.new("Part")`

`Bullet.CFrame = CFrame.new(tool.Handle.Position, mouse.Hit.Position)`

[`Bullet.Name`](http://Bullet.Name) `= "Bullet"`

`Bullet.Size = Vector3.new(0.7,0.7,0.7)`

`Bullet.BrickColor = BrickColor.new("Black")`

`Bullet.CanCollide = true`

`Bullet.Transparency = 0`

`Bullet.BottomSurface = Enum.SurfaceType.Smooth`

`Bullet.TopSurface = Enum.SurfaceType.Smooth`

`Bullet.Shape = Enum.PartType.Ball`



`local bodyVelocity = Instance.new("BodyVelocity")`

`bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)`

`bodyVelocity.P = math.huge`

`bodyVelocity.Velocity = mouse.UnitRay.Direction * 300`



`Bullet.Parent = game.Workspace`

`bodyVelocity.Parent = Bullet`



`game.Debris:AddItem(Bullet, 3)`

`end`



`-- Shooting`

`tool.Activated:Connect(function()`

`if debounce == false and ammo > 0 and reloading == false then`

`debounce = true`

`ammo -= 1`

`createBullet()`

`tool.Shoot:FireServer(mouse.Hit.Position)`

`tool.Sounds["Gun Shot"]:Play()`

`player.PlayerGui.AmmoGui.Frame.TextLabel.Text = "Ammo: "..ammo.."/"..MaxAmmo`

`task.wait(1.978)`

`debounce = false`

`elseif ammo <= 0 and reloading == false then`

`reload()`

`end`

`end)`



`-- UIS Reload`

`userInputService.InputBegan:Connect(function(inputObject, isTyping)`

`if isTyping then return end`

`if inputObject.KeyCode == Enum.KeyCode.R then`

`reload()`

`end`

`end)`



`-- Equip
function`

`tool.Equipped:Connect(function()`

`isEquipped = true`

`tool.Sounds["Gun Equip"]:Play()`

`mouse.Icon = "rbxassetid://"`

`player.PlayerGui.AmmoGui.Enabled = true`

`end)`



`tool.Unequipped:Connect(function()`

`isEquipped = false`

`mouse.Icon = "rbxassetid://"`

`player.PlayerGui.AmmoGui.Enabled = false`

`end)`







https://redd.it/1jdll70
@r_lua
Could i do this more "compact"? or just how it is now?
https://redd.it/1jdny7d
@r_lua
Lua web playground (like Go playground)
https://redd.it/1jdt9yu
@r_lua