The smallest working mod. You write a Luau file, then run it from your Geode mod's C++ with runFile.
Create a .luau file in your mod resources, for example Bootstrap.luau.
List it in your mod.json resources. See Installation.
print("Hello from Luau")See globals for print behavior.
Include the header and call runFile with your resources directory and the file name.
All public functions live in the imes::luauapi namespace.
LuauAPI exports include/LuauAPI.hpp through api.include in its mod.json.
#include <Geode/Geode.hpp>
#include <Geode/loader/ModEvent.hpp>
#include <imes.luauapi/include/LuauAPI.hpp>
using namespace geode::prelude;
namespace lua = imes::luauapi;
$on_mod(Loaded) {
auto result = lua::runFile(Mod::get()->getResourcesDir(), "Bootstrap.luau");
if (result.isErr()) {
log::error("script failed: {}", result.unwrapErr());
}
}See Getting started for the main-thread rule.
$on_mod(Loaded) already runs on the main thread, so call runFile directly there.
LuauAPI owns the runtime, so you do not start it. Check status() is Ready first if you need to.
The file name must be a flat .luau resource name inside the resources directory you pass.
See Installation for how Geode packs resource files.
See modules and Limits and errors.
LuauAPI ships a built-in script executor. It is an ImGui window where you write Luau and run it live in the game. Turn on Enable Developer Mode under Developer Settings in LuauAPI mod settings, restart the game, then turn on Enable Script Executor. The executor toggle appears only after developer mode is on. Use it to test snippets without a build step.
src/api.cppinclude/LuauAPI.hppsrc/core/Runtime.cpp