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
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
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
How to configure the level of detail from IntelliSense during auto-completion suggestions for Lua?
https://redd.it/1nx7ard
@r_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
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
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
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
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
GitHub
GitHub - BirdeeHub/tomlua: Speedy toml parsing for lua, implemented in C (Warning! work-in-progress!)
Speedy toml parsing for lua, implemented in C (Warning! work-in-progress!) - BirdeeHub/tomlua
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
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
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Generic Inference Test
I have implemented a generic type inference system for https://github.com/EmmyLuaLs/emmylua-analyzer-rust, inspired by
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: 我们应该删除
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
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
GitHub
GitHub - EmmyLuaLs/emmylua-analyzer-rust
Contribute to EmmyLuaLs/emmylua-analyzer-rust development by creating an account on GitHub.
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
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
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
I made a Pydantic inspired library for Lua tables validation.
https://github.com/SymonBezerra/stellar-types
https://redd.it/1nynhbh
@r_lua
https://github.com/SymonBezerra/stellar-types
https://redd.it/1nynhbh
@r_lua
GitHub
GitHub - SymonBezerra/stellar-types: Validation library for Lua tables (object schemas), inspired by Pydantic.
Validation library for Lua tables (object schemas), inspired by Pydantic. - SymonBezerra/stellar-types
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
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
YouTube
WinUI3 for Lua Preview
Discover the preview for winui module for LuaRT that will support WinUI3
Bringing the full power of modern Windows desktop interfaces to the simplicity of Lua noscripting.
This module bridges the gap between native Fluent UI design and lightweight, expressive…
Bringing the full power of modern Windows desktop interfaces to the simplicity of Lua noscripting.
This module bridges the gap between native Fluent UI design and lightweight, expressive…
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
https://redd.it/1nzm3td
@r_lua
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
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
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
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
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
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
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
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
I'm building a platform that lets you create Roblox games without any code. What features would you want to see?
https://lobbies.dev
https://redd.it/1o3puea
@r_lua
https://lobbies.dev
https://redd.it/1o3puea
@r_lua
lobbies.dev
lobbies.dev | AI-Powered Multiplayer Game Creation on Roblox
Create entire multiplayer worlds on Roblox using only text prompts. Join the waitlist to be the first to build with AI.
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
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
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Push the Button: Using LuaJIT + FFI + CoreBluetooth with an async design to automate a trivial task
https://github.com/mogenson/switchbot.lua
https://redd.it/1o52xjr
@r_lua
https://github.com/mogenson/switchbot.lua
https://redd.it/1o52xjr
@r_lua
GitHub
GitHub - mogenson/switchbot.lua: Use LuaJIT + FFI + CoreBluetooth to push the button
Use LuaJIT + FFI + CoreBluetooth to push the button - mogenson/switchbot.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 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
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
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
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
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
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
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
GitHub
GitHub - 2dengine/sstrict.lua: Detect mistakes in your Lua source code
Detect mistakes in your Lua source code. Contribute to 2dengine/sstrict.lua development by creating an account on GitHub.
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
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
GitHub
GitHub - NotHurtGarci/dispel: Dispel is a modern Lua runtime backend built on a C/LuaJIT core.
Dispel is a modern Lua runtime backend built on a C/LuaJIT core. - GitHub - NotHurtGarci/dispel: Dispel is a modern Lua runtime backend built on a C/LuaJIT core.
Should I use Lua 5.4 or 5.5?
Hi everyone. I'm close to releasing an app that uses Lua heavily. I've decided not to go with 5.1 or LuaJIT, because I want my app's users to have full access to the latest libraries on LuaRocks, and the widest compatibility with the general Lua ecosystem. But I'm on the fence about using 5.4 or 5.5. On one hand, clearly 5.5 is the future, and eventually I'll have to update to it anyway. On the other hand, 5.5 is still in beta, and I'm not sure how many LuaRocks modules would be incompatible with it. Any feedback would be helpful and appreciated.
https://redd.it/1o5q167
@r_lua
Hi everyone. I'm close to releasing an app that uses Lua heavily. I've decided not to go with 5.1 or LuaJIT, because I want my app's users to have full access to the latest libraries on LuaRocks, and the widest compatibility with the general Lua ecosystem. But I'm on the fence about using 5.4 or 5.5. On one hand, clearly 5.5 is the future, and eventually I'll have to update to it anyway. On the other hand, 5.5 is still in beta, and I'm not sure how many LuaRocks modules would be incompatible with it. Any feedback would be helpful and appreciated.
https://redd.it/1o5q167
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community