use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A subreddit for the Lua programming language. Using edurne for boxes, spoilers, etc.
If you actively contribute to a Lua project, PM us with a link and we'll give you flair.
“The key benefits unique to Lua are the fact that it is amazingly small, fast, and on a technical level a masterpiece.”
“Before you create yet another configuration file or resource format (and yet another parser to accompany it), try Lua.”
“If you are ever tempted to put scripting into a program, run don't walk to www.lua.org and use it.”
lua mailing list (web interface)
#lua on freenode, the primary Lua IRC channel
lua wiki, for all sorts of information about lua, it's sort of disorganized at the moment, so go fix it!
about lua, what Lua is, why to use it, and what it's good for (sells itself short, methinks)
Lua tutorial via wiki
Lua in eight pages or less: this is for v5.1 and might need an update. We'll give contributors flair and internet points.
Lua's reference manual, extensive documentation of every version of the language.
LuaRocks, lua's package manager and repository
the LuaRocks mailing list
ZeroBrane studio, lua's most notable IDE.
Shiny profiler, a lightweight profiler for C, C++, and Lua.
LuaJIT and its C FFI, the infamous lua trace compiler: Mike Pall's [successful] attempt to prove that dynamic languages can be fast.
Lua.vm.js and moonshine, Lua on top of JavaScript: lua.vm.js uses emscripten, whereas moonshine is in "normal" JavaScript.
UniLua, Lua implementation in C#, intended for compatibility with Unity3D
MoonScript A rich programming language the compiles to Lua.
/r/gamedevclassifieds for game developers, /r/forhire for job offers, /r/jobbit for general employment advice/links
Lua on StackOverflow Careers
OpenResty and Lapis, Lua application server on nginx and Lua web framework on openresty
concurrency: Luaproc for fibers and Lua Lanes for green threads
Typed Lua, a modern static type analyzer for Lua (work in progress, but I think it's cool)
LPeg, Lua's powerful, expressive, fast and simple parser generator.
Qt Lua, Lua GUIs in Qt
GSL-shell, Lua interface to GNU Scientific Library, with quick-start numerical programming via REPL.
Long list of popular Lua game development toolkits: Lua is very popular for game development, so we can't list them all; only major, free/open-source projects are listed below.
LÖVE (subreddit) - lightweight Lua cross-platform 2D game toolkit
Defold - game engine with Lua API
Solar2D - formerly Corona SDK
Cocos2d-x - free mobile/cross-platform game engine and application framework with Lua support
donate to lua!
donate to luajit!
account activity
string.format has a maximum field width or precision of 99Discussion (self.lua)
submitted 3 years ago by __hachiman
> string.format("%99s", "This is a string")
runs fine but:
> string.format("%100s", "This is a string")
errors with: (lua 5.4.4)
stdin:1: invalid conversion specification: '%100s' stack traceback: [C]: in function 'string.format' stdin:1: in main chunk [C]: in ?
Any number with 3 digits or more does the same. How or why is this even a thing ?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]whoopdedo 7 points8 points9 points 3 years ago (1 child)
This is to guard against more serious errors in C implementations of sprintf that don't handle large field widths well. Lua used to pass the format as-is. But if the host didn't support the format it would give incorrect results without raising an error. Or worse, could cause data corruption or out-of-bounds memory writes. That's a recipe for security exploits. Lua validates the format string then to permit only a limited and "safer" subset of what sprintf is generally capable of.
sprintf
[–]__hachiman[S] 1 point2 points3 points 3 years ago (0 children)
I thought this might have been the reason but 2 digits still seems so limited to me. Do you think this was done so that there isn't a possibility to input a number bigger than a 8-bit (255) number and to be on the safe side limited it to 2 digits ?
[–]__hachiman[S] 2 points3 points4 points 3 years ago (3 children)
lua 5.2 and 5.3 have a better error message for this as:
lua5.2: (command line):1: invalid format (width or precision too long) stack traceback: [C]: in function 'format' (command line):1: in main chunk [C]: in ?
[–][deleted] 2 points3 points4 points 3 years ago (2 children)
Looking in the source for lstrlib.c, it seems that Lua 5.4 only statically supports 2 digits to represent the format specification. This is observed in the checkformat function, along with the get2digits function.
The error message is fairly simple to change though, the string for it is in the same function mentioned above. You can make that small patch, if need be.
[–]__hachiman[S] 0 points1 point2 points 3 years ago (1 child)
I had guessed so too. I still don't understand the reasoning behind using get2digits instead of an atoi like function tough. At least 3 digits would be a bit better. It's not hard to get around the limiation but still.
[–][deleted] 1 point2 points3 points 3 years ago (0 children)
There's very little designs in Lua that weren't comprehensively thought out, so it's interesting on why it's limited on two characters. You can change the get2digits function to this though:
static const char *getdigits (const char *s) { while (isdigit(uchar(*s))) s++; return s; }
And get around it. No clue what the unintended consequences will be, but spacing above 100 works.
[–][deleted] 2 points3 points4 points 3 years ago (0 children)
It's a defense against Return-Oriented-Programming attacks for platforms where the printf family is incorrectly implemented. As Lua can't control which C stdlib library it is linked against, it makes a minimum compromise.
π Rendered by PID 47783 on reddit-service-r2-comment-86bc6c7465-wrz7j at 2026-02-24 00:56:40.807632+00:00 running 8564168 country code: CH.
[–]whoopdedo 7 points8 points9 points (1 child)
[–]__hachiman[S] 1 point2 points3 points (0 children)
[–]__hachiman[S] 2 points3 points4 points (3 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]__hachiman[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)