rlua documentation

I know using lua bindings should be pretty straightforward, but there aren't any pieces of documentation anywhere (wiki, website, raylib repo, or this repo) about how to use them. I imagine a lot of new people stumbling in don't know file structure or setup for lua bindings, and it might make the difference in being able to pick up this lib.


  • Hi box, you're completely right, there should be a minimum of documentation about using the binding... I just didn't find the time to write some documentation... it's in my long TO DO list... sorry... :(

    Just added rlua.c (https://github.com/raysan5/raylib-lua/blob/master/rlua.c) some days ago, it's a launcher program to execute raylib lua files, actually, that file launcher uses raylib lua binding.

    I'll try to add some documentation as soon as possible.

  • boxbox
    edited February 2017
    No apologies. You have a wonderful library. I know you have a million things to do with it. I'm just new to both C and Lua (JS/Java/Go experience), so the setup has been more than I'm used to. =)
  • I was pondering if it could be possible to compile rlua with emscripten, and intergrate the result to accept instructions from a simple text box.
    The result will be a online editor that can run raylib lua code. It could be?
  • Yes, I think it's possible but it will require some frontend work to integrate with a good online code editor. Writting the code and playing pressing a button wouldn't be difficult.

    A more interesting project would be an editor with the possibility to see changes in realtime, I mean, you keep updating code and when it's correct, changes are automatically visible in the game (like Unity does). To do that, it would be better to limit Lua code to just the Update() logic of the game... but, well, it requires some additional work... ;)
  • That's real time stuff would be really awesome.
    But let's take it simple for now, even a online editor where you can run Lua file (with error code reported back) will allow lot of users to try your lib. Or even better build some simple web game (without even download emscripten).
    To be clear this is out of my knowledge right now, hope some more capable than me will grow the idea.

    I believe right now "rlua.exe" should at least return TraceLog() messages. Very difficult to spot any error otherwise.

    Have a good day.
  • edited April 2017
    Yeah, that's a good project but requires some time...

    About TraceLog() messages, I can enable them, don't know why I disabled them...

    Just added in latest commit in GitHub!
  • Thanks for updating the win32 release. Now it works as expected.
    I see no change in the source-code, is TraceLog a compile option?

    I'm facing some issue in compiling rlua (both as exe and emscripten), do I have to reference also raylib? It says "rlua.h:102:19: fatal error: utils.h: No such file or directory"
  • Actually, showing console output is a compiler option, I mean TraceLog() messages are always enabled, what I hide on compilation is console. It is done with the compiler option -Wl,--subsystem,windows.

    To compile rlua.c, just use the compiler line you find in header comments (in the same file). The issue you can face is that required headers are not found (for example utils.h). A quick fix is just copying that header from raylib/src directory into rlua.c folder.

    The proper fix is including required folders with compiler option -IC:\raylib\raylib\src
  • Sorry to bother you again, compiling with emscripten rise:

    emcc -o web_basic.html rluaWeb.c -O1 -Wall -std=c99 -s USE_GLFW=3 -s ASSERTIONS=1 --profiling -I. -I../../../src -I../src/external -I../release/html5 -L. -L../src -L../release/html5 libraylib.bc -DPLATFORM_WEB
    In file included from rluaWeb.c:46:
    ./rlua.h:903:5: error: implicit declaration of function 'SetDrawingLoop' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    ./rlua.h:903:5: note: did you mean 'lua_SetDrawingLoop'?
    ./rlua.h:898:5: note: 'lua_SetDrawingLoop' declared here
    int lua_SetDrawingLoop(lua_State* L)

    Seems like SetDrawingLoop is not defined?

    Anyway bypassed that problem I menage to compile rlua with emscripten as web app.
    Next step is merging with the code editor.. Thanks again.

  • Hi HomineLudens,

    Thanks for the report, actually, I didn't try to compile for web after some redesign I did over rlua.h (originally that library was implemented by a raylib user). It's great you manage to get it working!

    Lately I've been working on raylib examples, I plan to port those changes to raylib-lua in the following days... also thinking about some improvements on rlua launcher... ;)

    Again, thanks for the test, keep me updated! :)
Sign In or Register to comment.