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
How to start making games and stuff with lua for free?

I know theres roblox but try to avoid saying roblox or anything related to roblox, as im not a fan of the company.

Hello im a young adult with autism (if that maters), i struggle to learn things and be creative but yet i want to make a game or something of that nature. I still want to bypass theses struggles but where do i start with lua? i want to explore 2d and 3d but i feel like lua dosent offer much for 3d, i could be wrong.

https://redd.it/1j5ektj
@r_lua
Gmod LUA

Anyone able to tell me why this doesn't work???

function(ply)

if IsValid(ply) then

local pname = ply:Nick() -- Get the player's name

RunConsoleCommand("sa", "setrank", pname, "verified")

end

end



ERROR:

[mc_simple_npcs\] addons/mc_simple_npcs/lua/mcs_npcs/sh_npcspawn.lua:78: attempt to call method 'Nick' (a nil value)

https://redd.it/1j5h3jj
@r_lua
How to star with lua in Visual Studio

Hi all. I am a complete beginner to coding and have been trying to figure out lua in vs code. I have downloaded the lua binaries and the lua server extension and can run simple .lua files without issue.

However I am running into problems with trying to use the luahelper extension for debugging. The debug tool requires luasocket. To install luasocket I will need luarocks. To get luarocks to compile projects I will need mingw. I am wondering if there is a less painful way to get the debug tool to work, without making installations of things I do not understand?

https://redd.it/1j6pljn
@r_lua
Where Do I Start I Want To Learn Lua

im looking to learn lua but i don't got the money and im only 15 year old i try to learn in roblox game called noscripting school

https://redd.it/1j6ywbq
@r_lua
3D in Lua

Please, suggest me way to do my physics (science) 3D simulation experiments with Lua.

https://redd.it/1j72maq
@r_lua
Sphinx-Lua-Ls: generate beautiful documentation for your Lua project using Lua Language Server and Sphinx

So, I've made a Sphinx plugin that uses Lua Language Server to automatically document your project.

Unlike other tools, this gives you flexibility of Sphinx combined with power of Lua Language Server analysis.

See the example output here (generated from this code), the rest of the documentation is here.

I'll appreciate your feedback and bug reports or feature requests, you can submit them to GitHub.

# Why?

There are several documentation tools for Lua, and none of them were suitable for my project:

1. `sphinx-lua` is another Sphinx plugin for Lua, and the inspiration for this project. Unfortunately, it only supports emmy-lua annotations, and has a number of bugs and missing features; plus, the author hasn't been active since 2023 and doesn't accept pull requests. I wanted to contribute new features to it initially, but writing a new version from scratch proved to be easier.
2. `LDoc` is probably the most well-known one. Its annotations clash with Lua Language Server ones, so you'd have to choose one or the other. It is also limited by rigid structure of its output. It is great for quickly generating API references, but starts lacking with you need something advanced.
3. `doxyrest` is another Sphinx-based tool, but it uses Doxygen as a code analyzer, and, well, Doxygen is the weakest part in this project.

# Caveats

1. By default, sphinx-lua-ls will assume that comments in your code are written in reStructuredText. If you want Markdown, use MySt plugin.
2. Lua Language Server's output is not complete at the moment (see notes here). You might need to adjust your comments for better output.
3. This tool doesn't support C/C++ Lua extensions. If you have those, you'll have to document them manually, or use `LDoc` instead.

https://redd.it/1j7mn0l
@r_lua
Question about LuaJIT: when is a roundtrip from lua to C and back to lua illegal?

Hi all, I am confused about the following section from the luajit [website ](https://luajit.org/ext_ffi_semantics.html#init_table:~:text=One%20thing%20that%27s,function%20(or%20similar))

I am planning on writing a modding library in luajit. Thus lua(jit) code will be responsible for placing code hooks into an application and detour the execution into luajit. However, I am not sure if this is allowed given the paragraph on the website.

>One thing that's not allowed, is to let an FFI call into a C function get JIT-compiled, which in turn calls a callback, calling into Lua again. Usually this attempt is caught by the interpreter first and the C function is blacklisted for compilation.

>However, this heuristic may fail under specific circumstances: e.g. a message polling function might not run Lua callbacks right away and the call gets JIT-compiled. If it later happens to call back into Lua (e.g. a rarely invoked error callback), you'll get a VM PANIC with the message "bad callback". Then you'll need to manually turn off JIT-compilation with [jit.off()](https://luajit.org/ext_jit.html#jit_onoff_func) for the surrounding Lua function that invokes such a message polling function (or similar).

For example, I would write something like this:

// file: original.cpp
void render() {
doRender(); // bla bla
}

-- file: injection.lua
function customRender()
doCustomRender() -- more lua code
end

callback = ffi.cast("(void *)()", customRender)
hookingLibrary = ffi.load("myhookinglibrary.dll")
hookingLibrary.placeHookIntoMemory(addressOfOriginalRenderFunction, customRender)

Will `customRender` be optimized by luajit? When will it and when will it not?

https://redd.it/1j82199
@r_lua
Need is a drop in replacement for require

https://github.com/burij/lua-light-wings/blob/main/modules%2Fneed.lua

I wrote a little module, which makes it faster to require modules. You only need to put it in the project directory and require it in a normal way. Then if you do

local module = need "module"

It looks in different common locations for this module (can be easily extended, which exactly), if it doesn't find it, it tries to download it via luarocks and require then.

It is possible to pass a second argument. If you pass an URL as second arg, it will download and require then. If you pass any other string, it will try that on lua luarocks aswell (for the cases, if the module name on luarocks doesn't match the filename, for example you could do:
local lfs = need ("lfs", "luafilesystem").

https://redd.it/1j86i1s
@r_lua
LuaX - Like React, but it supports any UI library (beta)

Today I released version 0.5.0 of LuaX, which is a library I've been working on that allows you to create interfaces using "html with lua" syntax attached to any UI library. It's written in pure lua, and happened to be my first time developing a language parser of any sort. Currently, it supports Gtk Via LGI, the web via Fengari, and AwesomeWM's wibox widget system. There are code samples for Gtk and the web in the repository.



Unfortunately my documentation is still lacking somewhat, but I'd love to hear people's opinions on it. My eventual goal is to write a standardized component library, so cross-platform lua app development would be a breeze.



https://github.com/oezingle/LuaX

https://redd.it/1j8mwon
@r_lua
Newbie question - how to display values of a table in alphabetical order?

I'm working on a simple word game which includes a list of words that the player is trying to guess. I'm implementing this with a table of values in which the keys are the words and the value for each one is true if the player has already guessed it and false if not. I want the player to be able to review the words they've already correctly guessed, and I want the words displayed to be in alphabetical order. Getting the program to display only the true flagged words is easy enough, but I don't know how to get it to sort the words. What can I do to sort the keys and display them in the order I want?

https://redd.it/1j8yanm
@r_lua
Gmod Lua Darkrp configuration help

Does anyone know how to disable the popups for players changing teams and changing names? Also the sound? I cannot figure it out

https://redd.it/1j98p8t
@r_lua
Made my first working code in a programing language guys...
https://redd.it/1j9w6j1
@r_lua
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