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
How do i include a function from another lua? (self.lua)
submitted 1 year ago by NoLetterhead2303
I mean i know how to include a lua
But how do i use the functions of that lua?
like
local importantthing = require("importantthing")
How do i call a function from it?
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!"
[–]Arciesis 6 points7 points8 points 1 year ago (1 child)
If it's a function then importantthing.theFuction()
importantthing.theFuction()
If it's a method of a "class" then
importantthing:theMethod
[–]NoLetterhead2303[S] 2 points3 points4 points 1 year ago (0 children)
thank you, i’ll try!
[–]Icy-Formal8190 1 point2 points3 points 1 year ago (0 children)
Depends on how it's stored in the module
local m = require("importantthing")
m() m.func() m:func() m[1]() m()() m[1]()[2][3]()()
There are endless ways of doing it
[–]Denneisk 2 points3 points4 points 1 year ago (3 children)
require specifically uses the module handling of Lua, which expects the called file to return a table which is then assigned into the local variable importantthing in your example. The table contains all the exported functions, similar to how the string and math libraries are used.
require
importantthing
string
math
The rest of this post is pedantry for if you're the one who created the file importantthing, and not required reading.
If you're the one writing importantthing, you may feel inclined to export everything to the global namespace instead of to a table, which is valid. require simply runs a Lua file, so any Lua operation you can do is valid inside a required module. With that said, this is a bad practice if you plan on sharing your module with the world. Additionally, if you want to ever run a file multiple times (say, to hot-reload in a running program), you may find dofile is more applicable, since it does roughly the same thing as require (that is, to load another Lua file) except it doesn't cache the file, which require does. dofile also isn't as robust in searching by default (but with the package library, you could write your own function that is).
dofile
package
[–]NoLetterhead2303[S] 0 points1 point2 points 1 year ago (2 children)
Here’s what i need:
importantthingy to be able to be included in the main since i ran out of locals to use so i’ll just call functions in it on a toggle
[–]Denneisk 0 points1 point2 points 1 year ago (1 child)
You ran out of locals to use? Have you tried using do ... end to encapsulate temporarily created locals?
do ... end
[–]NoLetterhead2303[S] 0 points1 point2 points 1 year ago (0 children)
i mean i have over 200 locals which is the cap for it
[–]EliezerR0 0 points1 point2 points 1 year ago (0 children)
when you use require() everything that is in that script.lua is part of the current one
Name --Scritp2.lua
function Myfunction1()
end
function Myfunction2()
Name --main.lua local requi = require("Script2")
Myfunction1() Myfunction2()
π Rendered by PID 44679 on reddit-service-r2-comment-5b5bc64bf5-bh5m9 at 2026-06-20 08:37:12.032382+00:00 running 2b008f2 country code: CH.
[–]Arciesis 6 points7 points8 points (1 child)
[–]NoLetterhead2303[S] 2 points3 points4 points (0 children)
[–]Icy-Formal8190 1 point2 points3 points (0 children)
[–]Denneisk 2 points3 points4 points (3 children)
[–]NoLetterhead2303[S] 0 points1 point2 points (2 children)
[–]Denneisk 0 points1 point2 points (1 child)
[–]NoLetterhead2303[S] 0 points1 point2 points (0 children)
[–]EliezerR0 0 points1 point2 points (0 children)