22,969 questions
Best practices
0
votes
1
replies
17
views
Lua learning for fxcm
I want to learn, writng code in lua for fxcm(marketscope) so im looking for a resource to learn it step by step.
I have a strategy that takes too long, manually so im intended to turn it to the code ...
Best practices
1
vote
9
replies
104
views
When is it appropriate to use the "Async" suffix when naming a function? Yield, or non-blocking, or both?
Let's say I named a function DoSomethingAsync.
Now, without running it. Do you think it yields, or runs immediately, but returns something later, and allows the caller to continue running more stuff ...
4
votes
1
answer
71
views
Why is a recursive Lua function calling itself via a local alias instead of directly?
Below code is from nmap tableaux.lua script file which is located at /usr/share/nmap/nselib
local tcopy_local
function tcopy(t)
local tc = {}
for k, v in pairs(t) do
if type(v) == "table&...
2
votes
1
answer
52
views
How to refresh nvim-tree filters after modifying a custom ignore file at runtime?
I’m using lazy.nvim to load nvim-tree.
I extended nvim-tree to read a project-local .fdignore file and use it to hide files/directories.
This works on startup, but changes to .fdignore are not ...
1
vote
0
answers
40
views
nvim restoring last cursor position
In macos, I have the following in my ~/.config/nvim/init.lua:
vim.api.nvim_create_autocmd("BufReadPost", {
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
...
0
votes
0
answers
47
views
Catch `otherMouseDragged` event in Hammerspoon
I am totally new to Lua. The main idea is to use my logitech mouse but not the buggy and resource-eating Logi Options+ application. I try to implement these actions :
Btn 4 click : Mission Control
...
1
vote
0
answers
176
views
Is it normal for pattern matching to take forever when used on a 600kb+ string?
Take a look at the following code:
local contents = assert(io.open("foo.html", "r")):read("*a")
print(string.len(contents))
string.find(contents, ".+\"url\"...
3
votes
1
answer
124
views
Karatsuba Square Root implementation correctness
I'm currently trying to implement Karatsuba Sqrt for my BigInteger module in luau, though I'm having trouble with its accuracy and I don't know what I'm doing wrong.
Karatsuba function:
local function ...
Advice
1
vote
4
replies
179
views
Pygame or Love2d for game development?
I have been looking at frameworks for game development and I have found that pygame (a python game development libary) and love2d (a lua game development libary) seem the eisiest to learn. I also know ...
4
votes
1
answer
82
views
inlay hints don't work for golang in neovim?
i have hints working for lua, but not for go.
i've already tried a bunch of stuff like several go configs, though it seems like it is a server problem, because Settings: {} is what i get in ...
1
vote
0
answers
80
views
neovim treesitter and mini.ai
I found out the mini.ai html tag selection is very bad but treesitter was so good at it so I decided to change it to treesiter without loosing the good things in mini.ai so I did this config and so ...
1
vote
1
answer
931
views
How to finish Tree-sitter plugin in Neovim by Lazy.nvim?
I am a newbie Neovim user and I am configuring Neovim by Lazy in init.lua. However, I had a problem when installing Tree-sitter plugin by Lazy.nvim.
In file init.lua, I use below command to install ...
1
vote
0
answers
63
views
Error while configuring jdtls on neovim 0.12 without using any plugin
I am trying to run jdtls lsp on the latest nvim 0.12 with minimal setup without using any plugin for my nvim version:
NVIM v0.12.0-dev-5299967
Build type: Debug
LuaJIT 2.1.1764270282
However, when i ...
3
votes
1
answer
61
views
Object and entity colliding multiple times regardless of disabling cantouch property
I am creating a game about fighting other people in arenas, and when 2 people are in the arena, anyone that tries to enter becomes a spectator, for some reason, the part you touch to enter the arena ...
Best practices
0
votes
7
replies
149
views
In lua, is there a way to "force" an argument to its multiple values
Let tableA = {"a","b","c"}.
print( table.unpack(tableA) ) will print : a b c - the multiples values of table.unpack(tableA) are displayed,
print( table.unpack(tableA) , &...
2
votes
0
answers
77
views
Neovim LuaSnip configuration problem, Lua snippets work correctly but JSON doesn't
I have an NvChad configuration for NeoVim, and I was trying to configure a LuaSnip plugin, but for some reason my Lua snippets are working correctly, but the json ones do not, and I want to figure out ...
4
votes
1
answer
112
views
How to evaluate arithmetic expression in pseudo‑SQL style (Lua 5.1)
In love2D I have a string that represents a mathematical expression, for example:
local expr1 = "[p35] div [p36]"
local expr2 = "((([p35]*100) div [p36]) mod 100)"
local params = {...
Advice
0
votes
3
replies
82
views
String manipulation: extract words under brackets
I'm not yet very familiar with the patterns in Lua's string.gsub function.
If I have a string like this:
Fishing Lure(+100 Fishing Skill)(1 hour)
and I want extract only the string "1 hour"...
-4
votes
2
answers
116
views
Question regarding using : and [] together, Lua
Take the following block of code
function pickrand()
local v = math.random(1,3)
if v==1 then return ‘px' elseif v==2 then return ‘py' elseif v==3 then return 'pb' end
end
prin = {
x = ...
Best practices
0
votes
0
replies
46
views
Lua: install via rockspec a github project, no realease, no version
I'd like to install with rockspec lua-ext but I'm not sure what is the cleanest way to do it via rockspec:
it has no release and luarocks install --local https://github.com/thenumbernine/lua-ext does ...
1
vote
1
answer
94
views
How can I use `chansend()` to update a terminal buffer asynchronously in Neovim?
I have a callback/generator which produces output, possibly after a delay. I'd like to send these outputs to the terminal buffer as they're produced. Here's a mockup:
local term_buf = vim.api....
3
votes
0
answers
71
views
Run multiple test files from master file
I am building a test suite for my Lua application with Busted. I am organizing tests into different files that I would like to run in a given sequence, e.g. low-level unit tests first, up to ...
3
votes
1
answer
77
views
Explicit formatting of Format date/time regardless of operating system setting
As an an example:
print(os.date("%b"))
This prints "Oct" when running on a computer having date time settings set to English.
When using other language it prints "okt" (...
5
votes
2
answers
108
views
Is the condition "and true or false" redundant in Lua?
Inside a wiktionary module pages there is a function is_title() defined as:
function export.is_title(val)
if not (val and type(val) == "table") then
return false
end
...
1
vote
0
answers
55
views
Fluent Bit v4.1.1 – ${tag[1]} variable not set when dynamically naming OpenSearch index
Issue:
I’m using Fluent Bit v4.1.1 to send Docker container logs to OpenSearch.
I want to dynamically extract the project name (e.g., test-project) from the log file path /logs/test-project/... using ...
0
votes
0
answers
80
views
Running bash script with Lua and Tup causes file permission issues
I am running a legacy C++ build env with Tup, Lua5.4 on Debian13. When I run tup, under any user (also root) there are strange file permission issues. When I debug and do and "ls -l" the ...
1
vote
0
answers
77
views
How to rotate a model?
I have a code for rotating the turret model, but the mesh rotates, but the turret model also has a gun, but it either freezes regardless of the mesh rotation or simply does not rotate
local Players = ...
1
vote
0
answers
150
views
How setup Neovim for Haxe programming language (LSP and Treesitter)
Hello people on the internet.
I made my own Neovim config https://github.com/Mr-Fox-h/fox-ide and it's a good config, but I want to write codes with Haxe programming language. I installed haxe and ...
0
votes
0
answers
103
views
Require is returning a nil value in GLua for a module
I'm trying to create a module through the best practice means rather than package.seeall. Below is the code I've used. I'm running into an error where once I run require("mylibrary"), m ...
0
votes
1
answer
62
views
Access parameters from rockspec
I have a rockspec that requires compiling some C sources. I am using the make backend to do that, and my Makefile has a way to switch compile and install flags depending on variables passed to it.
Now,...
2
votes
1
answer
100
views
luarocks init not injecting project tree into lua wrapper package.path
When I run luarocks init in a directory that has a rockspec file, the tree in lua_modules/share/lua/5.1 for my project isn't added to the project.path of the generated ./lua wrapper so modules ...
0
votes
0
answers
105
views
mkottman/AndroLua: building from sources
I have a Lua integration inside my Android Application (basically printing to Bluetooth printer routines). I already has built .so libraries of AndroLua and it works fine. Recently Google sent a note ...
0
votes
0
answers
110
views
How can I change the camera's CFrame while still having standard camera controls?
I'm trying to invert the depth of the camera (multiplying the camera's CFrame by (0,0,0, -1,0,0,0,1,0,0,0,1). To my knowledge, the only way I can implement this is by setting the camera type to ...
0
votes
0
answers
89
views
Error loading lsqlite3 module for love2D due to "symbol not being found"
Follow-up to this question
My current project folder includes the main.lua file, a .db file, , a sqlite.lua file from this somewhat old page, and a lsqlite3.so file copied from my homebrew folder. ...
1
vote
0
answers
115
views
how to avoid error loading lsqlite3 module for Love2D?
Important edit: it think that the issue might come from the fact that I'm using a Mac that uses an Arm64 processor. However, I'm not entirely sure since I don't know what that means.
I'm trying to use ...
0
votes
0
answers
55
views
Execution just stops after taking a screenshot
This is a minimal version of my init.lua hammerspoon config
https://gist.github.com/Touniouk/9b7f61f5d283a1514a386b1068ec8810
My goal is to
Take a screenshot of an app
Read some text on it
Click a ...
1
vote
1
answer
243
views
Added biome.json with default config, formatting suddenly works - did vtsls switch to biome automatically?
I was trying to get semicolons added automatically using <leader>fm in NvChad. It wasn't working before, so I added a biome.json file to my project directory:
{
"javascript": {
&...
0
votes
0
answers
96
views
Ball bounces off walls but not off tiles in PICO-8
I’m working on a small PICO-8 project where multiple balls/pixels should bounce around the screen.
The wall collisions work fine, but when I try to make the balls bounce off map tiles (with flag 0 = ...
5
votes
1
answer
128
views
In Lua, why is this example (from Programming in Lua 1st edition) true?
I use SQL and R at work but I am brand new to Lua. (I'd like to learn it, among other new skills, so that I can eventually make mods for Baldur's Gate 3. Not sure that makes a difference but this is ...
1
vote
1
answer
101
views
How could I zoom into a point (mouse positon) on a grid canvas?
(I've seen some similar-ish questions to mine, but they do not really apply to my case.)
I am scripting on a custom canvas for a program plugin using Lua. Drawn onto the canvas is a grid of squares, ...
0
votes
1
answer
182
views
How to capture the plaintext chunk passed to loadstring in an obfuscated Lua (Luraph-like) stub (Lua 5.1/LuaJIT, no debug lib)
I’m working with an old, unsupported Lua addon (Lua 5.1/LuaJIT). Its entry script appears to be a Luraph-style bootstrap that eventually calls loadstring with a decompressed chunk. My goal is not to ...
0
votes
0
answers
256
views
Can't get Avante.nvim to accept suggestions with custom keybindings
I'm trying to configure Avante.nvim to work with GitHub Copilot, but I can't get the suggestion acceptance keybinding to work. The suggestions appear correctly in insert mode (in gray text), but none ...
3
votes
1
answer
104
views
How do variable binds/closures work in lua
I'm a bit confused on how 'binding' works in lua. The following function (neovim) defines a callback within vim.keymap.set() to be called later involving the bufnr from the outer scope. Now coming ...
3
votes
3
answers
196
views
Declaring a variable as 'local' when outside Lua functions
I understand the difference between the scope of local and global variables, but I am confused about the difference and effects of declaring a variable OUTSIDE of Lua functions (or LOVE2D core ...
2
votes
1
answer
223
views
How to run a function everytime I enter Insert Mode in Nvim?
i am making a small plugin for myself and i just want to run a simple command whenever I enter Insert mode.
Currently i have tried the following
vim.api.nvim_create_autocmd({"InsertEnter"}, {...
0
votes
0
answers
43
views
Apache lua_mod setup: "lua: Unable to find function fetch_token_hook in <script directory>"
We're trying to run a lua script to hook into fixups phase of a request in an apache server app, but we keep getting the following:
"[Thu Aug 28 09:55:37.099004 2025] [lua:crit] [pid <<pid&...
3
votes
1
answer
105
views
Why is it not possible to extend a function call expression returning multiple values with another value on the right in Lua
Consider this test case.
function test()
return 1, 2, 3
end
-- OK: prints 4 1 2 3
print (4, test())
-- NOT OK: prints 1 4
print (test(), 4)
Why do values returned from a function in a function ...
1
vote
1
answer
89
views
Expression returning different values when using/not using math.floor()
I have an expression: ((12 / 10) - 1) * 10)
I need to floor the result to convert it into an int. When I do that with math.floor(), I get different results:
-- a. Unfloored value
print(((12 / 10) - 1) ...
0
votes
0
answers
135
views
Nmap running with very trivial script as argument not throwing expected string expected to be triggered depending on TCP port state (open/closed)
I failed trying to get to work a very simple Lua script inside a testy2closed.nse (Nmap Script Engine).
Tried on Mac and Linux, neither worked. Nor adding the script to the nmap scripts path (...
0
votes
0
answers
54
views
Zerobrane Path not finding files...how do I set it?
I'm using Zerobrane Studio (2.00; MobDebug 0.803) on Windows 11. When I try to run/debug some code, I get:
: module 'strict' not found:
no field package.preload['strict']
no file '.\strict.lua'...