49 questions
3
votes
1
answer
91
views
What does "*all" mean in `io.read("*all")`?
I know format "*a" is used to read a whole file, "*l" used to read a line. But what does "*all" (which appears in the book Programming in Lua) mean? I also saw "*...
1
vote
1
answer
79
views
Lua 5.3: strange behavior with table index
so I was playing around with tables a bit and found this strange behavior:
folder1 = {1, 2, 3}
table.insert(folder1, "test") --4
folder1[5] = "test2"
print("#folder1: " .....
0
votes
1
answer
73
views
Lua nested table get all elements from table if element in table is set to True
Fruits = { apple = { ordered = true, amount = 10 }}
i have several different kinds of fruits in this table and i need to output everything where ordered=true to make it look like this:
apple ordered: ...
3
votes
1
answer
116
views
Zerobrane does not access environment
I am moving to Debian 10 from Ubuntu 20.04. Now Lua 5.3 is not finding my own modules using "require". Worked fine on Ubuntu before, I suspect I am missing something now...
Pointers are most ...
-1
votes
1
answer
133
views
Lua table examples are not working for me
I'm trying code from lua.org and from my 4th edition Programming in Lua hardcopy, and as far as I've read all these table examples should work but 3 out of 4 don't, and I cant find anything the docs ...
4
votes
0
answers
697
views
How can I decode the Lua 5.3 call stack from a memory dump?
I'm extending an application with an embedded Lua VM. My scripts sometimes cause it to crash, and I'd like to be able to make some sense out of the resulting crash dump (Windows).
Is there already a ...
2
votes
1
answer
1k
views
Why lua require won't search current directory?
say I've two files test.lua and m.lua in a folder, in test.lua as:
require("m")
then I run this file, howerver it raise an error:
lua: /Users/xx/works/scripts/test.lua:43: module 'm' not found:
...
1
vote
1
answer
504
views
Cannot Load C dynamic library with C Program compile with liblua.a (lua5.3)
I first download lua-5.3.5 , and put the source in my working directory and compile it with
make linux
so I got the liblua.a and lua binary file in ./lua-5.3.5/src.
And then I write a C Dynamic ...
0
votes
0
answers
897
views
attempt to index a nil value (global 'math'))
I am using lua to make scripts in my game,
after updating the lua libs version from 5.1 to 5.3, an error appears on the game engine every time I use
math.X in a function
error :
Lua run doFile ...
2
votes
1
answer
301
views
Managing Lua 5.3 ".0" behavior
In Lua 5.3, when a number is a float without any decimal part, printing it adds ".0" to the end of it, giving me the wrong answer in golf and speed competitions. Rounding or ~~x or x|0 forces it to be ...
4
votes
1
answer
1k
views
Set _ENV from C++ for string function
In my project I'm executing some lua functions contained in an XML file. I read the XML from C++, parse the code strings, execute them and get the result.
All of the related questions I have found ...
0
votes
1
answer
190
views
How to Convert a string to lua code to read value from nested table
I have a configurable value of a table fetch function which i get as an input string. I need that string to be executed as a code and fetch a value from the nested table.
I tried using load(string), ...
2
votes
2
answers
873
views
Why isn't my LUA interpreter able to handle string key values?
When testing code with both a predefined script and the LUA runtime environment, LUA will not take any form of string key values. However, if a numerical value key is used LUA will work with it as ...
1
vote
0
answers
548
views
Changing the _ENV of a lua_thread (using C API)
This is for a multiplayer game where NPC scripts will be loaded and cached as function chunks on a single lua_State, and then each time a player interacts with an NPC, a new lua_thread is created, a ...
1
vote
1
answer
94
views
How do Lua syntax rules differ between REPL and scripts?
I rarely use Lua so this might be a trivial question but I just noticed that with Lua 5.3.2, in the interactive REPL I can write for example:
> 1 == 2 or error('numbers not equal')
Which is how I'...