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
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
Tips for debugging?

I seem to spend 90%+ of my coding time on debugging / trying to figure out why something isn't working, and so I'm wondering if anyone has any general tips on how to debug more efficiently. I use a lot of print() statements to look at variables and stuff, but I wonder if there's anything more I could do to speed along my debugging process. I should mention that I'm not the most experienced coder, and am relatively new to lua.

Also, I saw in the debug library / manual (?) (https://pgl.yoyo.org/luai/i/debug.debug) that apparently you can use debug.debug to "enter an interactive mode with the user" and "inspect global and local variables, change their values, evaluate expressions, and so on." I'm wondering how this can be done? I'm able to enter this interactive mode, however I don't know what commands to enter in order to do the aforementioned things. Where can I find a list of commands for this? I can't seem to find any additional information on debug.debug anywhere aside from this snippet.

Any help / discussion on the topic of effective debugging practices would be appreciated!

https://redd.it/1cof008
@r_lua
Best Lua IDE for begginer in may 2024

Hello! I would like learn Lua for better understanding for gamedev. I have little experience in few languages.
I tried to install LunarVim, but... I even cannot understand how to install "make" from prerequisites for Windows.
Also, I prefer open source, so, I avoid Sublime Text, Jet Brais or Visual Studio.
At first time I need only training and practice Lua language in Windows.
Are the best items for begginer:
1) VScode with Lua extention;
2) NotePad++;
But may be I did overlook something else?

https://redd.it/1com0hm
@r_lua
Logitech G600 Right mouse click, left mouse click, and, middle mouse click refuse to appear in output.

I am toying around with Logitech G Hub Lua noscript's and cannot get an output message when pressing RMB, LMB, and MMB, all other mouse buttons register. I have searched all over google and in multiple subreddits as well as the Logitech G HUB Lua API V2023.5 Overview and Reference, this seems to be a problem only I have which is very strange, hoping someone can help.

Code:

EnablePrimaryMouseButtonEvents(true)

// Enables LMB clicks to be registered, apparently all other mouse buttons are already enabled.

function OnEvent(event, arg)

OutputLogMessage("Event: "..event.." Arg: "..arg.."\n")

// Correct me if I'm wrong but this should output all registered events.

end

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