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

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

Powered by : @r_channels & @reddit2telegram
Download Telegram
how to learn noscripting from 0

how to learn lua from 0 to high lvl. how much time i need to spend for it?
whicih sites better to use? maybe youtube?

​

https://redd.it/1c3dw59
@r_lua
This media is not supported in your browser
VIEW IN TELEGRAM
Does anyone know the code where once you trigger the jump key, the player will jump and then go down, I'm a newbie with lua so it would be greatly appreciated to anyone who could solve this problem
https://redd.it/1c3h049
@r_lua
is there anyone who deobfuscates luraph?

like a discord server that offers luraph deobfuscation (paid)

https://redd.it/1c3wl9w
@r_lua
Adding a functions for a metatable(Class) defined in another module?

I'm basically trying to add a function in treesitter nvim for a node similar to `my_node:named_child_count()` returns the amount of named child node `my_node` has but I want to define it in my plugin e.g.:

useage:
`my_node:nodePrint()`

declaration
```lua
function self:nodePrint()
local child_count = self:named_child_count()

print("Node chilndren count: " .. child_count)
return child_count
end
```

now the structure of my_node is inherited with a treesitter function defined in another module:
```lua
local r, c = unpack(vim.api.nvim_win_get_cursor(0))
vim.treesitter.get_parser(0):parse({ r - 1, c, r - 1, c })
return vim.treesitter.get_node()
```

that seem like this should be simple but couldn't get this to work so far, any tips?

https://redd.it/1c4gmbi
@r_lua
Programming Beginner Here

I'm trying to get into the world of programming, and I've heard a lot about lua and lua seems to be used in general things I want to eventually try and do myself, so does anyone here have any recommendations on how to get started, I ordered a few books but I feel as though talking to people would be the best way for me to learn, so I'm open to any suggestions!

https://redd.it/1c4uqxx
@r_lua
Help with Coordinates

Hello, i’ve recently found the cause of a really big bug in a game, and im trying to fix it. The bug is having a black screen and shortly crashing afterwards. The reason this happens, is because the game is setting the player’s coordinates very very high. My question, is how do you check if the number of the coordinates is higher than another number. For example:

if PlayerGetPosXYZ(0, 0, 0) > 1000000 — Im not sure how you would do this, this is why i just put the one number.

Sorry if this is really confusing. For more context, here is my code:

​

function coord()

while true do

Wait(0)

if not AreaIsLoading() then

x, y, z = PlayerGetPosXYZ()

end

if x, y, z > 10000, 10000, 10000 - - if the number of player coords is higher than 10000 for x, y, z then do such and such.

https://redd.it/1c5h5nj
@r_lua
PowerShell/Windows Terminal unicode inconsistency

I have this Lua noscript:

--test.lua
local s = io.read()
for i=1, utf8.len(s) do
local cp = utf8.codepoint(s,i)
print(cp)
print(utf8.char(cp))
end

Run in a PowerShell terminal through the Terminal app:

C:\>chcp 65001
Active code page: 65001

C:\>lua test.lua
abæ
97
a
98
b
230
æ

C:\>

Notice the nonascii 'æ' gets printed and with it's codepoint value of 230

If I do the same from a regular PowerShell window (i.e. not through the Terminal app):

C:\>chcp 65001
Active code page: 65001

C:\>lua test.lua
abæ
97
a
98
b
0


C:\>

Now the 'æ' is not correctly interpreted.

I was debugging in VS Code and noticed this during of the sessions. At first I thought it was a problem with how VS Code ran the terminals, but it is apparently a more general difference between the regular PowerShell (and CMD) app and when it's run through the Terminal app. What gives?

https://redd.it/1c63qgb
@r_lua
Metatable type to ensure types passed store proper values

I've been trying to get my Bezier table to inherit the style requirements of type Curve<Bezier> so that I can define multiple different types of curves (bezier, arc, line segment array) that utilize similar methods. I'm trying to ensure that the "blueprint" table passed into the metatable's second argument stores the functions required to make it a curve, and also that the first argument (the table that will become a metatable) has the fields required to make it of the type Bezier, or whatever else I choose to define. Below is the code I currently have, in which you should be able to glean my general idea.

type CurveImpl<T> = {
index: CurveImpl<T>,
new: (...any) -> Curve<T>,
GetPoint: (self: Curve<T>, t: number) -> Vector3,
GetTangent: (self: Curve<T>, t: number) -> Vector3,
GetAcceleration: (self: Curve<T>, t: number) -> Vector3,
SetContinuous: (self: Curve<T>, position: Vector3?, tangent: Vector3?) -> (),
string: ((...any) -> any)
}

type Curve<T> = typeof(setmetatable({}::{
-- The parameters detailed in the T type should go here. (In this case, the Bezier type.)
}, {}::CurveImpl<T>))

local Bezier: CurveImpl<Bezier> = {} :: CurveImpl<Bezier>
Bezier.index = Bezier

type Bezier = {
Controls: {Vector3}
}

function Bezier.new(...: Vector3): Curve<Bezier>
return setmetatable({Controls = {...}}, Bezier)
end

Of course, there are more methods that satisfy the requirements for a `Curve`, but they have been omitted for brevity.

https://redd.it/1c6mfc5
@r_lua
According to the SWIG website, Lua is not a noscripting language
https://redd.it/1c6qrmg
@r_lua
Is it possible to convert hex to lua?

Hello!
So, I have this mousepad with lights around it, I took out the main chip with the button that turns on and off the lights, I used CH341A Programmer to "read" it and got something which i think is HEX and I want to edit that but of course i cannot understand random numbers so I would like to know if it's possible to convert it to some other programming language like lua or something to edit the chip

Sorry if you didn't quite understand what I'm trying to do

thanks

https://redd.it/1c716kf
@r_lua
lua is too hard to install

Installing Lua:

Search a bunch of web pages trying to find windows binaries

extract the zip

manually add it to PATH

Installing Python:
Download installer from official website

Run installer


genuinely the easiest way to install lua is the ComputerCraft mod for minecraft


https://redd.it/1c76p3y
@r_lua
Is there any good latest reference for lua learning and development?

I am looking for some lua turtoial for lua study/There is a lot of out-of-date documents online but I would like find the lastest version to learn. Please give some suggestions.

https://redd.it/1c7dffy
@r_lua
Anyone know any good roblox lua tutorials for someone with good knowledge of python



https://redd.it/1c7hmsn
@r_lua
How to write a universal path on my code?

Hey! Sorry for the dumb question. I`m pretty new at coding and I also know very little on writing Lua code

I`ve been wanting to write a piece a code that creates a .txt file on Desktop upon activating a certain trigger. So far, it works as intended, but the path to which writes this file is only possible if I write exactly my own directory (including my user name). So of course this code only works on my PC.

But I`ve been wanting to make this code work for every computer, writing this same txt file on everyone`s desktop.


How can I write this pathing to make it universal?

function onBegin()
local file = `io.open`("C:/Users/My username/Desktop/Textfile.txt", "w")
file:write("My text")
file:close()
end

Thanks!

https://redd.it/1c7mdjk
@r_lua
Help with downloading Lua

So, I'm new to programming and learning Lua rn. I'm trying to download Lua but I just can't. All the tutorials I've seen just show how to use it in windows cmd. I don't know if I'm just stupid, but can anyone help me download the actual Lua app. Thanks.

https://redd.it/1c8zn9x
@r_lua
Why does it say Im attempting to index a nil while Im not??: Roblox Lua

soo I have a noscript that manages the bots pathfinding and other stuff. I defined the humanoidrootpart but for some reason, in a function it says that my rootpart is trying to index nil with "Position". I dont know why this s happening


the function Im talking about:

local function Pathfind(destination)
local path = Pathfinding:CreatePath(PathInfo)

path:ComputeAsync(RootPart.Position, destination.Position)

return path
end



RootPart is the humanoidrootpart and the destination position is the position for the random waypoints



local function Wandering(Location)

local path = Pathfind(Location)

if path.Status == Enum.PathStatus.Success then

for i,Waypoint in pairs(path:GetWaypoints()) do

if iswalking == false then

local Target = TargetPlayer()

local Player = game:GetService("Players"):GetPlayerFromCharacter(Target)

if Target and Target.Humanoid.Health > 0 and Player:FindFirstChild("Safe") and Player.Safe:IsA("BoolValue") and Player.Safe.Value == false then

Attack(Target)

break

elseif walkingToDoor==false then

RootPart.CanCollide = true

movingPart = Location

Hum.WalkSpeed = normSpeed

AnimWalk()

value.Value = false

if iswalking == false then

Hum:MoveTo(Waypoint.Position)

end

Hum.Died:Connect(function()

respawned()

end)

local moveTime = Hum.MoveToFinished:Wait()

if not moveTime then

IsStuck(true)

else

IsStuck(false)

end

end

end

end

else

local DoorDetect = FindDoor()

if DoorDetect~=nil then

walkingToDoor = true

Hum:MoveTo(DoorDetect.Position + RootPart.CFrame.LookVector * 2)

Hum.MoveToFinished:Wait()

walkingToDoor = false

Wandering(Location)

else

walkingToDoor = true

Hum:MoveTo(Location.Position)

RootPart.CanCollide = false

Hum.MoveToFinished:Wait()

walkingToDoor = false

end

end

end


local function RandomPartWalk()
local waypointsParts = PathwaysParts:GetChildren()
local RandomNum = math.random(1, #waypointsParts)
Wandering(waypointsParts[RandomNum])
end


local AI = noscript.Parent.Parent
local Pathfinding = game:GetService("PathfindingService")
local Hum = AI:WaitForChild("Humanoid")
local RootPart = AI:WaitForChild("HumanoidRootPart")


the AI is the rig model

https://preview.redd.it/y58jk9twi8wc1.png?width=652&format=png&auto=webp&s=d2f45939f83f16ae4620004dec2007546a8d7b7f

the issues seems strange because it works on other games but not on my main game


the error line is:
path:ComputeAsync(RootPart.Position, destination.Position)

https://preview.redd.it/v1izps8yi8wc1.png?width=919&format=png&auto=webp&s=eba9577801e1305057dc1d96d2a37e994c46b048


Soo I tried some stuff and i changed this things:


path:ComputeAsync(RootPart.CFrame.Position, destination.CFrame.Position)

and this is what it gave me as error:

00:41:56.106 Workspace.Dummy.Configuration.Ai:503: attempt to index nil with 'CFrame' - Server - Ai:503


then I tried to check if the rootpart or destination is a nil and if yes it should return nil:

if RootPart == nil or destination == nil then

return nil

end

path:ComputeAsync(RootPart.Position, destination.Position)


and it gave me this error:
00:44:48.473 Workspace.Dummy.Configuration.Ai:514: attempt to index nil with 'Status' - Server - Ai:514


which is basically this line:

if path.Status == Enum.PathStatus.Success then


so I changed it to this and it actually fixed the error:


if path == nil then

return

end


I got the npc working but it is really broken. Any help?

https://redd.it/1cb5aql
@r_lua
How does comparison of a var to a string work?

say you have some code that runs several times a minute

if Some.foo.bar == "Number One" then executeThis(); executeMore()
elseif Some.foo.bar == "Number Two" then

...

end


just wondering if lua will take the constant value string and compare every time. Or if it will hash the constant value and then just compare our var to a hash each time. Or something else

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