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
Why doesnt this noscript work?
https://redd.it/1fmsd6r
@r_lua
What even is noscripting

I gave up on luas complete basics long time ago but i never understood the concept of noscripting in general how does it work and in what way people make it work (would love some extremely basic noscript that kind of showcases that)

https://redd.it/1fmz6b5
@r_lua
Garry's Mod Attempt to index boolean value

I'm writing code for a weapon in Garry's Mod, trying to check if a trace didn't hit anything to exit a function early, but for some reason attempting to invert the value of TraceResult's Hit field causes this error. If I do not try to invert it, no error occurs. Failed attempts to invert the value include !tr.Hit, not tr.Hit, tr.Hit == false, tr.Hit ~= true, and finally, true ~= tr.Hit. I can't think of any other options to try. How is this code trying to index Hit?

Rest of function:

function SWEP:PrimaryAttack()
local owner = self:GetOwner()

print( owner )

local tr = owner:GetEyeTrace()

PrintTable( tr )

if ( not tr.Hit ) then return end

-- More code that never gets run due to erroring conditon
end

https://redd.it/1fn1g7a
@r_lua
logitech G-Hub G-Keys remapping?

Can you somehow simulate the press of a G-key? I would need a letter key to be a G-key to make my noscript work. Is this possible I tried remapping via powertoys but it was not registered as a g-key press.

https://redd.it/1fn9g30
@r_lua
How the hell do I install luarocks!?

I want to install luarocks for an existing lua installation I have which is on a different hard drive from my main one.

I have 2 main folders, one called `Lua`, which holds the lua installation (5.4.2 btw) and one called `Luarocks`, which holds the luarocks.exe. In the `luarocks` folder, I have a subfolder, called `rocks` where i want the rocks/plugins/libraries/whatever to go. I don't care about local or global rocks as I'm the only one using this computer.

So far, powershell (im on windows btw) recognizes luarocks. I have 3 main problems though.

1 Plugins are in `AppData\\Roaming` (I want the rocks to go in the `rocks` folder as mentioned earlier)



2 It keeps asking me to set the lua interperter directory whenever typing in `luarocks list` even though i keep doing what it says:Error: Lua 5.4.2 interpreter not found at S:\\Coding\\LanguageInstalls\\Lua\\Lua5.4.2 Please set your Lua interpreter with: luarocks --local config variables.LUA <d:\\path\\lua.exe>

What I put in and still get error afterwards:

luarocks config variables.LUA S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lua.exe



3 Whenever I try to simply require a module, (im requiring lunajson btw) I get this error:

S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lua.exe: test.lua:4: module 'lunajson' not found:
no field package.preload'lunajson'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lua\lunajson.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lua\lunajson\init.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lunajson.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lunajson\init.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\..\share\lua\5.4\lunajson.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\..\share\lua\5.4\lunajson\init.lua'
no file '.\lunajson.lua'
no file '.\lunajson\init.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lunajson.dll'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\..\lib\lua\5.4\lunajson.dll'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\loadall.dll'
no file '.\lunajson.dll'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lunajson54.dll'
no file '.\lunajson54.dll'
stack traceback:
C: in function 'require'
test.lua:4: in main chunk
C: in ?

With this noscript:

local lunajson = require("lunajson")

https://redd.it/1fnvhhw
@r_lua
Hi,I have a problem when trying to download the saitek panel plugin for the zibo.
https://redd.it/1fo0s5h
@r_lua
Tables and json

Hello, so basically what i am trying to achieve is to save the contents of a table to a .json file and make the table update and save from that file. For example, let’s say i have a table called Redtest how would i go about saving the contents of this table to a .json file and also use the contents within that file to update the current table. So if there are interruptions like crashes or something, i would have the data stored separately ready to use again and not lose all the data. Is there an efficient way of doing this? Any help would greatly be appreciated. Also if it helps i am using CfxLua.

https://redd.it/1fo3el3
@r_lua
"Go to Symbols in Workspace" is too slow in VSCode with Lau extension by sumneko

I am working on project where there are are roughly 5000+ lua files.

I am using VSCode (moving from Sublime) with extension Lua by sumneko. While all the other things are working well, what I see a huge drawback is the symbol search in workspace.

When I start typing a function name, it take like good 10-15s for it to show results. And any incremental char in the search field also takes some 10-15s. In Sublime it used to be fast even without any extension (VS code doesn't do it work without extension).


Has anybody faced this? Are there settings which can cache the result and show it faster?

Or any other extension which can do this better way?

https://redd.it/1fp1lu6
@r_lua
How to declare dependencies in lua packages

I am new to lua.

I am writing a lua module where I would like to implement some interfaces that are exposed by another third-party module that I have no control over.

How can I declare a dependency on that third-party module so that I can implement the exposed interface?

I did some digging and found that "luarocks" can help manage dependencies. But, I am uncertain if that's the preferred way?

At the end of the day, people using the third-party library can load my implementation of the third-party interface in their application. So, I believe, at runtime it'll be fine as people can define dependencies on both modules. But, for my local development, I don't know how to go about it.

I don't know if I'm sounding stupid.


Thanks for your help!

https://redd.it/1fplr7s
@r_lua
is there a way to implement scanner on lua?

I was just wondering if you could put a scanner like java.

https://redd.it/1fq32tc
@r_lua
Modding games

Okay so i know the games have an API that supports Lua, my book says to embed into the program i have to "Initialize The Lua State: #include<lua.h> ... " and gives code. my problem is the game is an executable how do i put that in the game. i feel like i am going about this wrong. Like Hades 2 everything is exposed cool. Starbound its JSON files and i managed. or do i just create a mod folder by it and drop files in that.


if anyone has any good sources for me to read or watch let me know, i want to learn to do this and i cant afford college.

https://redd.it/1fq9gjn
@r_lua
Need resources

Can i get recommendations for books or websites or youtube guides that help with self learning. I've picked up alot of python, but im not sure how to use the concepts i've learned. So im trying learn lua to dive into modding. Need a few sources.

https://redd.it/1fr1sq2
@r_lua
Is luarocks compatible with luau?

I have downloaded and ran luau on my computer, but when i tried to use it with luarocks (normal lua works fine) the require function gave an error:

test.lua:1: error requiring module
stacktrace:
C function require
test.lua:1

any ideas?

https://redd.it/1fri1bf
@r_lua
Recommend a Good Lua Codebase to Study

Is there a good open source lua codebase you'd recommend looking at for a beginner trying to grok the ways of lua? I can muddle through with a lot of googling and searching in the lua docs, but I think I might benefit from just looking at good lua code.

https://redd.it/1fs6aew
@r_lua
Ikibooru - a booru of generic files written almost entirely in Lua
https://mid.net.ua/ikibooru.html

https://redd.it/1fsanmh
@r_lua
So I tried Roblox Studio...

It eats 2GB RAM.

Has a Qtitan library around Qt5. LibFbxSDK probably the one from AutoDesk. WebView2 from Microsoft.

And yes, Luau is an interesting extension to Lua...

https://redd.it/1fsq7z6
@r_lua
fengari-web: Helper functions & ordered, async noscript loader

I've continued messing with Fengari, using it with some js libraries (pixi-js primarily). I do not want to use node, npm, webpack, etc. And, I got tired of require() putting deprecation warnings in my console about synchronous requests.

So, I created this loader and some global helper functions. If someone knows an easier way to do this, please share! If it's somehow useful or interesting...here it is:

<noscript type="application/lua">
js=require('js')
window=js.global
document=window.document

local modules={
'testmod.fengari',
'dramaterm.fengari'
}

await=function(p)
local pco=coroutine.running()
p'then'
coroutine.resume(pco,...)
end)
,result=coroutine.yield()
return result
end

Array = js.global.Array

-- Helper to copy lua table to a new JavaScript Object
-- e.g. Object{mykey="myvalue"}
function Object(t)
local o =
js.new(js.global.Object)
for k, v in pairs(t) do
assert(type(k) == "string" or js.typeof(k) == "symbol", "JavaScript only has string and symbol keys")
o[k] = v
end
return o
end

function import(js,t)
-- "imports" parts of a js library into global, for convenience
for
, v in ipairs(t) do
ENV[v]=js[v]
end
end

local loadScript=function(src)
local noscript = document:createElement('noscript')
noscript.type='application/lua'
local response=await(window:fetch(src))
local scr=await(response:text())..'\nloader(\''..src..'\')'
noscript.innerHTML=scr
document.head:append(noscript)
window.console:log('Loaded lua noscript',coroutine.yield())
end

local load=function(t)
for
,v in ipairs(t) do
loadScript(v)
end
end

loader=coroutine.wrap(load)
loader(modules)
</noscript>

https://redd.it/1ftkmqa
@r_lua
roblox banner tracker

hey, anyone knows how i can do a banner tracker of a game from roblox? idk if i need to use a noscript made in LUA to get the banner information or smth like that. I want to make this for my discord server

https://preview.redd.it/x26yk32so9sd1.png?width=508&format=png&auto=webp&s=2e2df773880e413822080ad47f6dd77cd79c8c67

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