Raylib LuaJit bindings that are generated from the raylib-parser API docs
-
raylib.h
code-gen to lua usingraylib_api.lua
-
rlgl.h
code-gen to lua usingrlgl_api.lua
-
raygui.h
code-gen to lua usingraygui_api.lua
-
config.h
code-gen to lua usingconfig_api.lua
-
raymath.h
code-gen to lua usingraymath_api.lua
- Simple lua files (except for the compiled Raylib binaries/libraries/header)
- Works as an actual lib instead of a runner
- No build required in order to use this
- Really easy to update
- You need the LuaJIT and Raylib compiled binaries/libraries
- Building a binary to distribute is a chore
- Install Raylib globally. I used
brew install raylib
on OSX, or - Download your Raylib release and toss everything from
lib/
into the./raylib
folder - Create a file in the root with the following code:
-- save as main.lua
-- run with `luajit main.lua`
local rl = require('raylib')
rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.InitWindow(800, 450, "raylib [core] example - basic window")
while not rl.WindowShouldClose() do
rl.BeginDrawing()
rl.ClearBackground(rl.RAYWHITE)
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY)
rl.EndDrawing()
end
rl.CloseWindow()
- Run
luajit main.lua
Examples are pulled from TSnake41/raylib-lua
Run luajit examples/core_basic_window.lua
You can use the Raylib parser to generate .lua
files that document the API:
./raylib_parser -i ../src/config.h -f LUA -o config_api.lua
./raylib_parser -i ../src/raylib.h -f LUA -o raylib_api.lua
./raylib_parser -i ../src/raymath.h -f LUA -o raymath_api.lua
./raylib_parser -i ../src/rlgl.h -f LUA -o rlgl_api.lua
# requires the raygui in the raylib source folder
./raylib_parser -i ../raygui/src/raygui.h -f LUA -o raygui_api.lua
This is a work in progress as well. It uses regular Lua 5.4 to generate the file. Make sure lpeg
is installed. You can install it with luarocks install lpeg
.
It is super rough right now but it does work and generates a init.lua
file with comments and docblocks!
You don't need Lune or Luau installed to use this library
cd raylib/
luarocks install lpeg
lua generate.lua
Thank you to these projects that acted as a reference for this implementation