Lua - Reddit – Telegram
Lua - Reddit
30 subscribers
278 photos
31 videos
4.23K links
News and discussion for the Lua programming language.

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

Powered by : @r_channels & @reddit2telegram
Download Telegram
Why not more Lua in web development or games?

Lua used to dominate as a noscripting language in game engines. Now, it's not so much the case except the dying Cry Engine and Roblox (which I don't consider to be a "real" game engine). Everyone uses C# while spreading hate to Lua or other languages. I don't think C# is bad but it's definitely more verbose and is bloated with like five ways of doing the same thing and personally I'd use lighter languages.

Also, Lua has the Lapiz framework which I heard is really fast and I want to start creating products in it. Most start ups don't need Spring or Django, Lapiz is at the level of Flask and is very lightweight. Generally speaking, Lua is a very lightweight language that's just one step above C++, making it very close to the metal while being very simple.

So what exactly went wrong? I think the world would be a better place if Lua was used more often and it received more support - extremely easy to write C functions and wrap them as Lua function to noscript later. Again, I'm not saying Java or C# are bad. They are enterprise level languages, but not everyone needs that complexity and bloat.

https://redd.it/1nwoib7
@r_lua
How similar are Lua & Python?

Big newbie here, so bear with me.

From what I understand, both python & lua were written/created using a C framework & are a high level language.

So how closely related are they?

The reason I ask is because python is used way more often, it's taught in universities & there's millions of resources online which have huge communities using & testing them out. So the teaching for python is just much more refined, tried & tested.

I was curious if I could take python courses, use leet codes, YouTube, etc... to learn python & then as long as I learn the syntax for Lua, have I basically learnt both?

To preface, I need to learn Lua for my work & I want to learn it as best as possible (not necessarily as fast), for the sake of the argument, no time restrictions.

https://redd.it/1nwtw2j
@r_lua
How to configure the level of detail from IntelliSense during auto-completion suggestions for Lua?
https://redd.it/1nx7ard
@r_lua
Experimenting with Lua Bindings to iOS + Android UI

I've been playing with adding Lua bindings to the iOS framework SwiftUI and Android's Jetpack compose. This allows for noscripting native UI for iOS/Android apps.

Here's what the Lua API looks like so far...

local Text = nube.ui.Text
local Button = nube.ui.Button
local VStack = nube.ui.VStack

function nube.ui.main()
local count = nube.ui.State(0)
return VStack {
spacing = 10,
Text("count: " .. count.value),
Button {
label = Text("Increment!"),
action = function()
count.value = count.value + 1
end
}
}
end

The module is called "nube", and most of the APIs are modeled after SwiftUI's view primitives and React's state mechanism.

https://redd.it/1nx9fvr
@r_lua
tomlua: cjson for toml

https://github.com/BirdeeHub/tomlua

Hey everyone!

So, I wanted to use some toml from my lua code.

I looked around for options. I found 3 main ones. 1 hasnt been touched in 8 years, has dependencies and doesn't build well anymore. 1 was written entirely in lua which... yeah thats not gonna do.

The only one that felt fairly good was named toml-edit. But toml-edit is for editing existing toml and spends a lot of time doing things such as tracking comments and other such tasks. Its definitely going for something else, and it does it well. But it wasn't what I was looking for.

I wanted something fast with a simple API like cjson, for toml. I just wanted to read some toml files into lua tables. And I wanted a fast, tiny, no-dependency C library to do it.

A few weeks later, I now have one to offer you all.

https://github.com/BirdeeHub/tomlua

It is fast, and it has another great feature.

It allows you to read the toml directly into a table of defaults you provide from lua!

It will recursively update tables and append to lists which are present in the provided table of defaults, and it does so with basically 0 extra performance penalty.

This means not only is the parsing fast, it removes the next step you were going to have to do anyway! This makes it even faster in practice!

It can probably still be optimized further, but it is already speedy and has all its features and tests and is fully compliant with the toml spec, so it was time to release it!

Selfishly, I hope people use it so that I don't have to write as much config in commentless json.

https://redd.it/1nxnucb
@r_lua
Is lua easy to learn?

Recently I started to learn python and started to understand more and more of it, I also wanted to learn how to code with lua since I have so many ideas for a roblox game :)) but is lua difficult at all to learn? How does it compare to python ?

https://redd.it/1ny2fx6
@r_lua
Generic Inference Test

I have implemented a generic type inference system for https://github.com/EmmyLuaLs/emmylua-analyzer-rust, inspired by TypeScript, but I'm not sure if it's stable. If possible, please help by raising more issues.

Issue collection link: https://github.com/EmmyLuaLs/emmylua-analyzer-rust/issues/785

Some of the tests that have passed are as follows:

#test
fn testtypepartial() {
let mut ws = VirtualWorkspace::new();

ws.def(
r#"
---@alias Partial<T> { P in keyof T?: TP; }

---@param v {name?: string, age?: number}
function accept(v)
end
"#,
);
assert!(ws.checkcodefor(
DiagnosticCode::ParamTypeNotMatch,
r#"
---@type Partial<{name: string, age: number}>
local m
accept(m)
"#,
));
}

#test
fn testissue787() {
let mut ws = VirtualWorkspace::new();

// TODO: 我们应该删除T...功能, 改为泛型T遇到 ... 会自动收集其所有参数合并为 Tuple 类型
ws.def(
r#"
---@class Wrapper<T>

---@alias UnwrapUnion<T> { K in keyof T: TK extends Wrapper<infer U> and U or unknown; }

---@generic T
---@param ... T...
---@return UnwrapUnion<T>...
function unwrap(...) end
"#,
);
assert!(ws.checkcodefor(
DiagnosticCode::ParamTypeNotMatch,
r#"
---@type Wrapper<int>, Wrapper<int>, Wrapper<string>
local a, b, c

D, E, F = unwrap(a, b, c)
"#,
));
asserteq!(ws.exprty("D"), ws.ty("int"));
asserteq!(ws.exprty("E"), ws.ty("int"));
asserteq!(ws.exprty("F"), ws.ty("string"));
}

https://redd.it/1nyir8l
@r_lua
Is stack a type of recursion?

Not sure if this is the best place to post so I apologize if its not.

I've been trying to get my head around recursion (big newbie to programming) & I'm a little confused about the course I watched putting stack, LIFO & recursion together as topics. To me, recursion sounded very specific to the way some functions are carried out, whilst stack & LIFO are the way your entire code is read/executed.

Are stack & LIFO types of recursion, or are they all just the way your computer runs code?

https://redd.it/1nyimlb
@r_lua
Develop WinUI3 applications in Lua (WIP - Preview Video)

Hi everyone,

Here is a preview video of a new LuaRT module I'm working on that brings WinUI 3 support to the LuaRT Windows programming framework : https://www.youtube.com/watch?v=ghx1MSfTA1w

This means you will be able to build modern Windows desktop apps using pure Lua, with full access to Fluent UI controls, thanks to LuaRT builtin object oriented programming capabilities and asynchronous Task object implementation.

No need for C++, .NET, or heavy frameworks.

Native WinUI 3 integration

Clean, expressive Lua syntax

Compatible with LuaRT static compilation and binary modules

Example from the video with dependencies statically compiled as a standalone executable : only 600kb, no other dependencies (even Microsoft.WindowsAppRuntime.Bootstrap.dll is not needed)

This is a big step toward making professional-grade UIs accessible to Windows Lua developers. I hope to release a first version soon.

You can find more about LuaRT, the Windows programming framework for Lua at https://luart.org


https://redd.it/1nzltj8
@r_lua
How to detect memory leaks when working with LuaJIT FFI?

What the noscript says.

I'm trying to use LuaJIT FFI to make tiny-ish games for my Miyoo Mini with SDL. The issue is that I have no clue how one would check for memory leaks. It is relatively straightforward with valgrind for compiled programs, but is there anything similar to use with LuaJIT?

https://redd.it/1nzm3td
@r_lua
Lua noscript not working for turret in stormworks

Hello everyone who is here i need to help with this code scanAngle = 0

function onTick()
local tx = input.getNumber(1)
local ty = input.getNumber(2)
local tz = input.getNumber(3)
local hasPlayer = input.getBool(1)

local yaw, pitch

if hasPlayer then
yaw = math.atan2(tx, tz) / math.pi
pitch = -math.atan2(ty, math.sqrt(txtx + tztz)) / (math.pi/2)
output.setBool(3, true)
else
scanAngle = scanAngle + 0.02
if scanAngle > math.pi then scanAngle = -math.pi end
yaw = scanAngle / math.pi
pitch = 0
output.setBool(3, false)
end

output.setNumber(1, yaw)
output.setNumber(2, pitch)
end
This code is for turret in stormworks its need to find a seat and start shooting error is not working

https://redd.it/1o11yv4
@r_lua
Require modules are unknown

Hello,

I’m working with lua/love 2d because I’d like to learn game dev, but I have an issue concerning the require of modules. For whatever reason, it always cast my variable containing the module as « unkown » even tho the module in question contain types.

I use Zellij with lazyvim as a dev environment and I already have lsp setup.
In VSCode for example, I don’t have issues when importing modules that contain types.

Anyone had the same kind of problem when using neovim/lazyvim and lua types?

Thank you.



https://redd.it/1o3be8o
@r_lua
Indexing table constructor: return {2,8}dice(2) ???

I know that you can make it work by putting parenthesis around the table, but why doesn't it work without the parenthesis?

-- works
return ({2,8})dice(2)

-- doesn't work
return {2,8}dice(2)

https://redd.it/1o51g7h
@r_lua
Need to Learn how to Lua Script For roblox basics

i need to know Lua noscripting to make some games pls give me relativley quick and easy ways to learn

https://redd.it/1o5574w
@r_lua
I made a noscript that automates “Please Donate” and earned 80k+ Robux in 2 weeks

Hey everyone,
I’ve been experimenting with automation inside Roblox’s “Please Donate” game and decided to build a small noscript to handle all the boring parts — keeping the booth active, refreshing messages, and thanking donors automatically.

After running it for a couple of weeks, I ended up earning over 80,000 Robux completely AFK. I honestly didn’t expect it to work that well.

I’ve cleaned it up, made it beginner-friendly, and documented how to set it up safely without breaking any Roblox terms. If you’re curious about the technical side or want to see a demo of how it works, feel free to DM me or ask questions here.

Not trying to spam or break any rules — just wanted to share what I built and see if others would find it useful.

https://redd.it/1o59u1d
@r_lua
SuperStrict the first "linter" written in pure Lua

Super Strict is a Lua library (compatible with Lua 5.1, 5.2, 5.3 and LuaJIT) that finds undeclared variables and other minor mistakes in your source code. Super Strict tests your Lua noscripts during loading using static analysis. Super Strict is very secure because it can be used without downloading, installing or running any pre-compiled binaries.

The source code is currently available on GitHub and the documentation is hosted on 2dengine.com

https://redd.it/1o5ig07
@r_lua
Dispel, Lua Runtime

The other day I created Dispel, a runtime for Lua that aims to be something like Bun does in JavaScript. This is a personal project to understand how a runtime it's implemented and I want to do my best but I want to know which things might be interesting to add, let me know here!

Also if you want to contribute in the future once I add more code to suggest features or help with fixes, I leave the repo here:

https://github.com/NotHurtGarci/dispel

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