Lua - Reddit – Telegram
Lua - Reddit
30 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 does oop work (object oriented programming)

it might be deeper than this, but all i know is variables inside tables can have values, and those values can be called changed, and such. But then I see there is classes, methods, instances, attributes, and it makes me all confused. Could somebody explain what these are?

https://redd.it/1ckplva
@r_lua
How do I do a non-blocking read with LuaSocket 3.1.0-1?

I have this function:

local function nonBlockingRead(sock)
sock:settimeout(0)
local data, err = sock:receive("*a")
if err ~= nil then
if err == "timeout" then
return nil, nil
end
return nil, err
end
return data, nil
end

but the receive function always returns nil, "timeout".

https://redd.it/1ckvgap
@r_lua
Trying to figure out how to exit a LUA program mid execution with the C-API

Hello everyone,

I am trying to get a sort of fantasy console idea working on a raspberry pi pico, the system posseses the ability to receive keyboard inputs for writing and executing programs, however I want to make it possible that the user can press the escape-button on the keyboard to stop the execution of a running LUA-program. I have had no succes as of now achieving this.

https://redd.it/1cl04im
@r_lua
LuaJit - meta method eq does not work

in LuaJIT I'm trying to create objects with the __eq meta method, but it doesn't work, I tried with setmetatable, getmetatable, etc., but it doesn't work, is there any way I can do this in LuaJIT or does it only work for versions of Lua higher than 5.3?



https://redd.it/1cl1hf5
@r_lua
What is the best lua framework for making websites in 2024?

I'm a long-time **Python** programmer, using *Flask* and *Django*, but as time is passing I've planned to lower the level of programming languages, hear that **Lua** is the best language to integrate with *C/C++* and then random noscripts I ended up picking up a *LÖVE* with **Lua**, and now I plan to make **Lua** my main.



*If you allow me, I would like to expand the question to:*

**## Cool questions**

* - What is the best framework?
* - Which is more popular?
* - Tips for web development and organization?

**## Silly questions (no need to answer)**

* - Has anyone tried LÖVE and WEB APP (in the python world it would be pygame and flask)
* - I'm making with my brother a kind of roguelike (actually an interactive ascii map viewer with a terminal on the side where master can "move a1 to b3 OR a1 use heal 3d4") for a D&D Runeterra Tabletop RPG, any tips to take this project to the web

https://redd.it/1cl2xa3
@r_lua
Why doesn't it work?



x= math.random(0, 20)
If x <18 then,
print("x is less then 18")
else
print ("x is greater than or equal to 18")
the output is

It says "lua5.3: Main.lua:2: syntax error near 'x'"

https://redd.it/1cl3qh6
@r_lua
Is there an android app that teaches lua?

I'm planning on creating mods for one of the games I'm playing and I can't seem to find an app that teaches lua. I have a pc, but it's more comfortable to learn it on mobile (my preference only).

https://redd.it/1clc1en
@r_lua
Extension for hover tips in VS Code like ZeroBrane?

I'm pretty new to lua and love2d. I recently switched from Zerobrane to VS Code because I already know VS Code well. However, I do like the hover tips in Zerobrane. Is there any way to replicate this in VS Code? VS Code makes some suggestions while typing, but I can't hover over any code and see a list of parameters, etc.

https://redd.it/1cllesj
@r_lua
I made an OOP library!

That's it. Link is here: https://github.com/Germ210/LuaClasses. Hope it helps. Would love to have feedback. I know I'll use it in my next project

https://redd.it/1clwy7w
@r_lua
Decompiling Lua Issue

I'm working with the game GeminiLost from playfirst, they have an assets.pfp file that can be extracted using a BMS Script

After extraction it is possible to see lua noscripts that were compiled using lua 5.0.x

I try to use ChunkBake, luadec, unluac and they all always give the same error, using ChunkSpy it is possible to see that you can identify a large part of the file but at the end it shows an error at the end

ChunkSpy:392: bad argument #1 to `len' (string expected, got nil)

using ChunkBake:

ChunkBake: A Lua 5 binary chunk assembler
Version 0.7.0 (20050512) Copyright (c) 2005 Kein-Hong Man
The COPYRIGHT file describes the conditions under which this
software may be distributed (basically a Lua 5-style license.)
* Run with option -h or --help for usage information
ChunkBake:260: ok.lua:1: Error: unknown character or control character

using luadec:

luadec.exe: bad code in ok.lua

using unluac:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "unluac.decompile.Op.ordinal()" because the return value of "unluac.decompile.Code.op(int)" is null
at unluac.decompile.ControlFlowHandler.find_branches(ControlFlowHandler.java:344)
at unluac.decompile.ControlFlowHandler.process(ControlFlowHandler.java:118)
at unluac.decompile.Decompiler.decompile(Decompiler.java:136)
at unluac.Main.main(Main.java:98)

I'm confused, do I need to make any changes to all the .lua files in the game or is there an error when unzipping the .pfp file?

https://redd.it/1cminnd
@r_lua
Is Love2d good for creating a visual novel game?

Hello!😄
Do you think love2d is a good way to make a visual novel type game? Or do you think there's another better engine or framework for this? Also, is lua a good programming language for this type of game?

https://redd.it/1cmo5im
@r_lua
Lua table help

How would I go about defining this array/table?

local num = 1
dbase["ra"\][num\].name

I need to make a database with different catagories such as "ra", "me", "hh" etc.. and these cats have unlimited amount of items to be added, then each item number has it's information.

dBase[catname$\][catnum(int)\].name = "A gun"

dBase[catname$\][catnum(int)\].cost = 200

etc

etc



https://redd.it/1cn9unk
@r_lua
How do i make the code wait?

I'm new to coding, i'm starting with lua, i'm doing some tests, and i wanted to make a noscript with a conversation between two characters, i wanted the noscript to appear (so it would first do print("noscript") and then after some seconds the rest would print, but how do i do this? Well, i haven't finished reading the guide tho.

https://redd.it/1cnkw3g
@r_lua
Using Lovr as an API and not a runtime for game engine development

Hey, wondering if anyone knows a way to be able to use Lovr (LÖVR (lovr.org)) as an API with Lua and/or C?C++ instead of directly relying on it as a runtime. I know I need to build from source, but I don't know what to modify in order to do this. Really, all I want from it is the rendering, as I plan to implement my own stuff with other libraries.

https://redd.it/1cnmcsx
@r_lua
How to use structures correctly?

Trying to convert this code from python. One thing I read said Lua only has tables, but then another poster was told to use a struct. And I get an error saying I'm trying to index a null value? What am I doing wrong?

function Qrsqrt(number)
  x2 = number * 0.5
  y = number
 
  i = struct.unpack('>i', struct.pack(y))[0]
  i = 0x5f3759df - (i >> 1)
  y = struct.unpack('>y', struct.pack(i))[0]

  y = y * (1.5 - (x2 * y * y))
  y = y * (1.5 - (x2 * y * y))
 
  return y
end

print(Q
rsqrt(123.456))

https://redd.it/1cnxsd7
@r_lua
Unexpected generic for behavior

I have the following code:

local a = {1, 4, 5, 2, 6, 1}
a.n = 6

function itern (t, m)
t.z = math.min(t.n, m)
return
itern, t, 0
end

function
itern (inv, c)
c = c+1
print (inv.z .. ";" .. c)
if c <= inv.z then
return inv[c]
else
return
end
end

for i in iter
n(a, 3) do
print(i)
end

I expect it to produce the following result:

3;1
1
3;2
4
3;3
5
3;4

But instead I get the following:

3;1
1
3;2
4
3;5

I have no idea why that happens. Can someone help?

https://redd.it/1cnxni9
@r_lua
Séléné V7 released

Séléné is a framework to create events driven and massively multithreaded Lua application, especially in a MQTT environment. Thanks to its plugins, it can be used to create graphical dashboards. It is written in C.

This new version introduces :

C API to storage/collection classes
Weak linkage mechanism with module and 3rd party applications. The big added value is enforcing upward API compatibility. So Séléné can be upgraded without needed to recompile application using its libraries

The documentation is a bit outdated : a new automating documentation tool for multiple languages is required, but I wasn't able to find one. On the other hand, C and Lua comprehensive examples are provided.

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