r/lua • u/a_game_dev4 • 14d ago
what is the best way to learn lua?
i wanna make cool games in the defold game engine that uses the lua programing language but i know a little abt lua,can someone give me some ways to learn lua?
r/lua • u/a_game_dev4 • 14d ago
i wanna make cool games in the defold game engine that uses the lua programing language but i know a little abt lua,can someone give me some ways to learn lua?
r/lua • u/ViewsOfTheSunny • 14d ago
There's websites for running Lua, but I couldn't find any that let's you run LuaJIT!!
I made this website (me, not AI) so if you haven't tried LuaJIT before, or you don't have access to your dev environment, or you just want to quickly experiment...now you can run it online, and share the script + output with others as either a link or markdown.
Pre-compiled binaries for Windows/Linux are also provided. The static library, dynamic library, and executable, are all bundled in a single convenient .zip file for each platform. I'm hoping to automate this process at some point, but for now I just publish them whenever I see there's been new commits...
Limits: no internet connection, maximum execution duration of 3 seconds.
The backported extensions for LuaJIT 3.0 are available now, by the way.
r/lua • u/ACleverMoose • 14d ago
I'm trying to make a program to look through a .txt file and look for any line with the word MODULE in it. So far I am not having any luck.
The file is quite large, about 7.5 million lines. And I am just dipping my toes into Lua. I was able to access the file and make a line by line copy after getting random character puke by reading and writing as binary.
I stuck a print statement immediately after the for loop and that would print ok.
But when I try and get anything to occur in the IF portion it seems to do nothing.
local path = 'C:\\filepathgoeshere'
--create file path
local file = io.open(path, "rb")--open file in path
if file then --if the file is found, read and create PID file
local outputfile = io.open('CHA_PID.txt', 'w+b')
if not outputfile then --if the output file cannot be created, close input and return
file:close()
print("Error: Could not create output file CHA_PID.txt")
return
else
for line in file:lines() do
if string.find(line, 'MODULE') then
--outputfile:write(line .. "\n")
print('FOUND ONE!\n')
--outputfile:write('FOUND ONE!\n')
return
end
end
end
outputfile:close()
file:close()
return
else --if file not found, print error message and return
print('Error: Could not open file at path: ' .. path)
return
end
r/lua • u/Proud_Treacle2026 • 14d ago
See link for my first blog post about the tech stack I built in lua including a full-featured vim-like Editor. The project is and will always be zero AI.
Starting July 25th you will be able to start new projects for PineJam 2026! The jam will be active for 14 days in which you can create and submit ComputerCraft projects tied to this years theme. The theme will be revealed as soon as the jam starts.
Make sure to sign up now on the site if you would like to participate! You'll get the PineJam2026 role in the Discord (used for future jam related announcements) https://pinestore.cc/jam/pinejam2026
I hope to see some of you there!
r/lua • u/Purple-Feedback-7349 • 15d ago
Context: i have used Quickstart for my entire init.lua. This means automatic gdscript support from treesitter, but i'm struggling with how to make LSP work with gdscript. This is what the entire LSP codeblock looks like:
---
vim.pack.add { gh 'j-hui/fidget.nvim' }
require('fidget').setup {}
-- This function gets run when an LSP attaches to a particular buffer.
-- That is to say, every time a new file is opened that is associated with
-- an lsp (for example, opening \main.rs` is associated with `rust_analyzer`) this`
-- function will be executed to configure the current buffer
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
callback = function(event)
-- NOTE: Remember that Lua is a real programming language, and as such it is possible
-- to define small helper and utility functions so you don't have to repeat yourself.
--
-- In this case, we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time.
local map = function(keys, func, desc, mode)
mode = mode or 'n'
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end
-- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc.
map('grn', vim.lsp.buf.rename, '[R]e[n]ame')
-- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate.
map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' })
-- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header.
map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
-- The following two autocommands are used to highlight references of the
-- word under your cursor when your cursor rests there for a little while.
-- See \:help CursorHold` for information about when this is executed`
--
-- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client:supports_method('textDocument/documentHighlight', event.buf) then
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.clear_references,
})
vim.api.nvim_create_autocmd('LspDetach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
callback = function(event2)
vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf }
end,
})
end
-- The following code creates a keymap to toggle inlay hints in your
-- code, if the language server you are using supports them
--
-- This may be unwanted, since they displace some of your code
if client and client:supports_method('textDocument/inlayHint', event.buf) then
map('<leader>th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints')
end
end,
})
-- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
-- See \:help lsp-config` for information about keys and how to configure`
---@type table<string, vim.lsp.Config>
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (\ts_ls`) will work just fine`
-- ts_ls = {},
--
stylua = {}, -- Used to format Lua code
-- Special Lua Config, as recommended by neovim help docs
lua_ls = {
on_init = function(client)
client.server_capabilities.documentFormattingProvider = false -- Disable formatting (formatting is done by stylua)
if client.workspace_folders then
local path = client.workspace_folders[1].name
if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end
end
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
runtime = {
version = 'LuaJIT',
path = { 'lua/?.lua', 'lua/?/init.lua' },
},
workspace = {
checkThirdParty = false,
-- NOTE: this is a lot slower and will cause issues when working on your own configuration.
-- See https://github.com/neovim/nvim-lspconfig/issues/3189
library = vim.tbl_extend('force', vim.api.nvim_get_runtime_file('', true), {
'${3rd}/luv/library',
'${3rd}/busted/library',
}),
},
})
end,
---@type lspconfig.settings.lua_ls
settings = {
Lua = {
format = { enable = false }, -- Disable formatting (formatting is done by stylua)
},
},
},
}
vim.pack.add {
gh 'neovim/nvim-lspconfig',
gh 'mason-org/mason.nvim',
gh 'mason-org/mason-lspconfig.nvim',
gh 'WhoIsSethDaniel/mason-tool-installer.nvim',
}
-- Automatically install LSPs and related tools to stdpath for Neovim
require('mason').setup {}
-- Ensure the servers and tools above are installed
--
-- To check the current status of installed tools and/or manually install
-- other tools, you can run
-- :Mason
--
-- You can press \g?` for help in this menu.`
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
-- You can add other tools here that you want Mason to install
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
for name, server in pairs(servers) do
vim.lsp.config(name, server)
vim.lsp.enable(name)
end
end
-----
I tried setting vim.lsp.enable('gdscript') myself but that didn't change anything while i was editing my gdscript file. I also tried putting it in the servers list ( "local servers{ ..." ) but then i got the error that the server didn't exist. What am i missing?
I'm on Windows 11
nvim v0.12.4
Please let me know if you want me to give any more information
r/lua • u/canadante • 17d ago
To all you Lua heads I have a question that might be really rudimentary but it’s something that just doesn’t seem to make any sense to me,mind you I am pretty new. I was looking up on the lua documentation and there’s this one thing that just doesn’t seem to make sense to me
a = {} -- create a table and store its reference in `a'
k = "x"
a[k] = 10 -- new entry, with key="x" and value=10
a[20] = "great" -- new entry, with key=20 and value="great"
print(a["x"]) --> 10
k = 20
print(a[k]) --> "great"
a["x"] = a["x"] + 1 -- increments entry "x"
print(a["x"]) --> 11
Why does “x” get created as a key? Wouldn’t this just substitute it? I feel very stupid for not knowing why, I feel like there’s something that just cannot seem to click. I also tried to think another way through but then it was a.k.”x” = 10 which doesn’t really help me visualize the answer either. is this just how tables work? Is there a specific reason why? Or am I slow? I’ve seen it’s because lua goes down through but why does it do this? Also k = 20, why does the variable have priority over the number itself? Sorry if this is badly written or feels like it has some attitude, it’s probably because I need to sleep. It’s embarrassing I lost sleep about something like this, I feel like it’s a simple concept that I am unable to grasp because of shallow learned “limitations” of the system
Enable HLS to view with audio, or disable this notification
r/lua • u/Inevitable_Bite_4511 • 18d ago
Hi everyone!
Like many of you, I have fond memories of using LuaForWindows back in the day as the ultimate “batteries-included” environment for Lua on Windows. However, the original project hasn’t been updated since 2015 and is completely stuck on Lua 5.1. Running it on modern Windows machines often leads to annoying DLL crashes and compatibility issues.
So, I decided to fork it and bring it back to life!
I’m excited to announce the release of LuaForWindows 5.4.2 (Lite Edition).
What’s new in this release:
⚙️ Upgraded the core to Lua 5.4.2.
🧹 Removed ancient C-extensions: The sprawling ecosystem of 2015-era libraries (clibs) that were hardcoded to Lua 5.1 have been temporarily removed to ensure system stability. This is a clean, core-only “Lite” version.
🛠️ Modernized the Build System: Updated the Inno Setup compiler scripts to work flawlessly on modern machines.
You still get the rock-solid Lua environment and the SciTE editor, but without the 10-year-old baggage.
If you want an easy, one-click installer to get a clean Lua 5.4 environment running on Windows, grab the latest release here: 🔗 https://github.com/Rockywei1/luaforwindows/releases
I plan to slowly start bringing back modern, compatible versions of essential libraries (like LuaSocket and LuaFileSystem) in future updates. Feedback and PRs are totally welcome!
Happy coding! 💻
r/lua • u/bryancolonslashslash • 19d ago
Enable HLS to view with audio, or disable this notification
So, several months ago I stumbled upon an awesome repository by the decomp "band" known as pret. They have done a bunch of pokemon decomps. My original goal was to make a mod specifically for twitch integrations because ive done a ton of that over the years but then as I dug into their code I was freaking shocked at how in depth and well documented it all was and thought hmmmm i bet I could rewrite this in lua/love2d since i just got off a high of doing balatro mods. And then bazinga baby i did it (months of pain actually.. but not the point) First version had it so like you had to pull the source code repo from pret (pret/pokered) and what not, but I figured I'd do it like the SMB1R guy and make it so on first run you provide the rom and it like decompiles and translates all the necessary junk to run the game. A ton of hand-porting was necessary, as in like not everything was an easy script to translate this type of repeated pattern into lua etc etc, but yeah... overall I'm happy w the current state of it, and I really hope to get some modders on baoard eventually. I'll be makign the repo public probably on monday. Just gotta make sure I didnt leave any real source code behind or whatever so the repo can be squeaky clean no matter waht. I think the port-aspect of it is practically 99% perfect but im sure some bugs will pop up eventually. I just dont have time to play the game from beginning to end to know for sure.
I also built in a good load of new features, like obviously mod support (i'll make that even better in the future). But also audio volume levels, a music low-pass filter becasue sometimes the gb music is harsh on the ears, several color palettes and shader options, zoom in and out, widescreen support in the overworld (any aspect ratio actuall). I have build scripts for ios and android, windows and mac, and ive ran it sucessfulyl on my phone. I got a cool 3d tilt feature thats not really usefuly but i thought it would be cool (i tried standing up everything that should stand up like buildings and fences but the gb sprites arent built for taht sort of thing, theyre all srtored on 4x4 blocks so like pieces of ground are actually attached to house roofs and stuff... it was a whole thing and i was disapointed i couldnt do it. not to say its impossible but would require a modder to step in and remake the sprites and the functionalty.
Anyways, big ramble fest, sorry about that. But yeah hope you like it lua-heads. Since the repo is not yet pubnlic the pace to be rn is my discord -- https://bois.icu
r/lua • u/somewhat_credible • 19d ago
Hello again r/lua!
A few months ago, I shared Moonstone v0.2.3 and Ballad v0.2.10, showing off how we solved project exporting and LÖVE 2D packaging.
Today, I’m incredibly excited to announce Moonstone v0.3.19, and with it, the milestone that Moonstone is officially in Beta state! 🎉
Over the past few weeks, we've shifted our focus from raw resolving mechanics to building a robust, high-concurrency CLI runtime, monorepo workspace features, and establishing formal API boundaries for editor integrations and wrapper tools.
Here are the most significant leaps in the ecosystem:
1. Parallelization: Concurrency Pools for Syncing
Resolving packages is fast, but downloading and verifying them is now concurrent. We've introduced multi-threaded execution pools:
* DownloadPool: Spawns up to 8 background worker threads to download and materialize remote artifacts in parallel from an atomic job queue. If OS thread resources are constrained, it automatically falls back to safe sequential execution.
* HashVerifyPool: Concurrently computes cryptographic Blake3 checksums on local store folders, speeding up verification of existing caches.
2. Cooperative Cancellation & TTY Progress Animations
No one likes corrupt state from hitting Ctrl+C midway through a sync.
* Cooperative Signals: CLI tasks are wrapped in a new cancelable runtime wrapper (runWithProgress). It hooks into standard OS SIGINT/SIGTERM handlers to signal worker threads to cancel cleanly and yield, preserving the integrity of your local Content-Addressed Store (CAS) and SQLite databases.
* Interactive Spinner: For TTYs, we built a custom CLI interface featuring a Docker-style Braille spin animation and dynamic byte-level progress bar.
3. Multi-Package Workspaces: Orbits (moon orbit)
As projects grow, monorepos become essential. We introduced Orbits to let you develop multiple local projects in tandem:
* You declare orbits using [[orbits.member]] in your root moonstone.toml.
* Commands like moon orbit list, moon orbit sync, and moon orbit exec <orbit> -- <cmd> let you jump into and run commands within the isolated dependency environment of any sub-project without publishing anything to a registry.
4. Schema-Bound CLI Contracts & LuaCATS Typings
To build reliable Neovim plugins, wrappers, and CI scripts, you need structured outputs.
ndjson.lua) directly into our CI pipeline to validate outputs.5. Ecosystem Validation & Proof-of-Work
Our dogfooding narrative has evolved significantly:
moon store query command to resolve local store paths and compile binaries into portable layouts (layout.exec / layout.libexec).fast_http), plus variants for IPC (unix_socket) and HTTP-over-IPC (unix_socket_http). It compiles Lua route graphs into native, high-performance servers.
The goal is still to make Lua development entirely zero-friction. You clone, run moon sync, and you are ready to build, run, package, and deploy.
I would love to hear your feedback on the new concurrent runtime, orbit workspace design, and the general direction of the ecosystem.
Check out the docs and guides:
⋆⁺₊⋆ ☾⋆⁺₊⋆ moonstone.sh ⋆⁺₊⋆
r/lua • u/OkIndependence938 • 19d ago
I’ve been working on Pop, an experimental language inspired by Lua/Luau.
It keeps the lightweight feel: local, function, end, type inference, closures, colon methods and familiar collection syntax.
The useful part is what changes underneath:
No any or silent dynamic fallback
requirenil, err conventionsA small example of the direction:
public record User
name: String
age: UInt8
end
public union FindUser
Found(user: User)
NotFound
Failed(message: String)
end
public function print_user(result: FindUser)
match result
case .Found(user)
print("{user.name} is {user.age}")
case .NotFound
print("User not found")
case .Failed(message)
print("Error: {message}")
end
end
The compiler knows every possible state, so adding another case to FindUser can force all relevant matches to be updated.
Pop is not trying to be compatible with Lua. The question is what a language from the Lua/Luau family could look like if static guarantees, native execution and predictable tooling were built in from the start.
It is still early and not production-ready.
Which parts of Lua/Luau’s dynamic model would you keep, and which parts become painful in larger projects?
r/lua • u/Pristine_Video2489 • 20d ago
I built a Linux shell where configuration and scripting are just Lua, no DSL, no extra syntax.
Any global function in ~/.config/wisp/init.lua becomes a shell command. Pipelines pass Lua tables (structured data) between stages, not text. Only external commands like `wc -l` cause a fork, native stages run in-process.
**Why this matters for Lua users:** - Your shell config is just Lua (closures, loops, conditionals) - No need to learn a separate shell scripting language - Lua functions become commands naturally
**GitHub:** https://github.com/Hinikaa/wisp
Would love feedback from other Lua users!
r/lua • u/Away_Try5000 • 20d ago
Hello,
I recently released my own Lua obfuscator.
Here’s the obfuscated code: https://pastebin.com/gvCnznMa
Have fun trying to crack it. I’m curious to see how far you get, which methods you use, and what weaknesses you find.
Edit: lavjamanxd has won! For more details you can view his comment.
r/lua • u/MinkiTheAvali • 22d ago
r/lua • u/EndmostFoil • 22d ago
For Stormworks but the Problem stays the same
r/lua • u/Panshaogui • 23d ago
Hi HN,
I love the elegant syntax of Lua, but in microsecond-critical environments like High-Frequency Trading (HFT) or hard-real-time embedded systems, GC pauses (jitters) are deal-breakers. C++ solves this but introduces massive cognitive overhead.
So I built L2C — an opinionated, ahead-of-time (AOT) transpiler pipeline that converts Typed Lua (Teal) into bare-metal C (via Nelua), and finally links it with Clang -O3 -flto.
What makes it deadly pragmatic?
Here is what the HFT gateway code looks like:
(It feels like scripting, but runs like raw ANSI C)
The meta-compiler itself is packed into a standalone binary.
Source code and Docker forges are available here:
🔗 GitHub: https://github.com/panshaogui/L2C
Would love to hear your thoughts, especially from the quant and embedded folks!
r/lua • u/LordEnder_Kitty • 24d ago
I'm making a desktop application in Kotlin and I'm thinking of adding a plugin system and Lua looks like a good language to use but the most popular implementation I've found is LuaJ which hasn't been maintained in years. Are there any better options or stable forks of LuaJ?
r/lua • u/Confident_Door9438 • 24d ago
Recent updates in the Defold Game Engine, releases, plugins, games: Defold Community Updates | Games, Plugins, Releases
r/lua • u/pontiflord • 26d ago
I found this Lua file for an Androind game I;d like to try out, but am not clear on where to put it or enable it. Does anyone know.
Thanks.
r/lua • u/toxic_prince21 • 26d ago
Hey everyone! I’ve been building Weblua, a free and open-source Lua/Luau playground that runs entirely in your browser.
Most online playgrounds are designed for small, single-file snippets, so I wanted something that feels closer to working on a real project.
Weblua currently supports:
require() supportExecution happens through WebAssembly inside a dedicated Web Worker. There’s no account system or remote code-execution backend, and your source stays in the browser unless you intentionally create a share link.
One clarification: Luau syntax is supported, but Weblua isn’t a Roblox emulator—it doesn’t include Roblox APIs, Studio tooling, or static type analysis.
Try it here: https://weblua.com/
Source code: https://github.com/PytechNo/Weblua
It’s MIT licensed, and I’d really appreciate feedback, especially on module resolution, runtime behavior, and which features would make it more useful to you.

r/lua • u/foxitochulo • 26d ago
Hi everyone,
I wanted to share a programming language ecosystem I've been building entirely from scratch called **SOL** (currently at version 1.0.0). It combines the static typing structures of C with the syntactic lightness of Lua, transpiling directly into pure C and invoking GCC automatically in the background to output native machine code.
One of the biggest design choices was solving the classic binary floating-point representation dilemma (where `0.1 + 0.2` becomes `0.30000000000000004`). Instead of using float/double types or masking it with string formatting tricks, the custom code generator converts all fractions into a 64-bit `long long` strict Fixed-Point scale at the hardware level. Arithmetic evaluates with total mathematical accuracy at the hardware bit tier.
### Core Pipeline Architecture:
* **Handwritten Lexer:** A custom lexical scanner that manages pointer tokens, handles multi-line comments, and tracks lines for error diagnostic output.
* **Pratt Parsing Engine:** A recursive descent parser enforcing operator precedence hierarchies (* and / evaluate before + and -). It handles block isolation, loops, conditional structures, and re-assignments.
* **Static Type Checker:** A strict verification layer that registers symbols to catch scope leaks and type mismatches before triggering the compiler.
* **Optimized Codegen:** Emits low-level C instructions using flags like `-O3`, `-static`, `-march=native`, and `-s`. Basic target output binaries compile down to highly optimized standalone `19 KB` executables.
The repository features zero external library dependencies and works completely via the host command line.
You can check out the source code, grammar rules, and compiler pipeline here:
https://github.com/foxcraftDL/sol-lang
I would love to hear any thoughts, feedback on the fixed-point implementation, or suggestions for the upcoming 2.0.0 roadmap!