-
I'm using an older game engine and in it I'm running lua-5.1 or luajit interchangably, and I made some tries to get luau working, but it seems there are quite a bit of things that I have to solve. I thought I'd ask for help here and document my problems in the event that the authors want to prioritize making this easy to do. By just including luau in my cmake project I immediately run into these problems:
My strategy is to use whatever hacks I can to get issues like the above working, and to add some kind of shim project to re-introduce the io-module and other things that I need from standard lua, by basicly copying the lua-5.1 implementation. Any advice on how best to accomplish this would be very velcome! My main idea is to build luau using its headers, and try to use the standard lua-5.1 headers for dependencies, and just hope to solve all linker issues. Maybe i can trick luau to rename lua_pushcfunction with a macro, and not have to edit the source, or just rename it in the luau source and create a standard lua api wrapper. I will try to do this and document my efforts here, as luau have some properties I have been looking for a lot, I especially welcome the low-overhead debugger with native file-line and step support, since the one I have currently written is too slow and I have not been able to get reliable stepping. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 32 replies
-
This should be fixed as of latest release; note that you'd need to define LUA_LIB as |
Beta Was this translation helpful? Give feedback.
-
Looking at this further it seems the entire lua |
Beta Was this translation helpful? Give feedback.
-
Skipping by the io.close for now, the next hurdle is a crash when the engine is trying to push a C++ function as a c-closure: Illegal instruction seems to mean some kind of memory corruption, this is way over my head. It seems to run fine until this, but maybe the memory corruption occurs earlier somewhere, due to my hacks or how the engine uses lua. |
Beta Was this translation helpful? Give feedback.
-
I actually got my game to run now, very promising! Issues remaining for now:
I am in general very happy with my shim project adding require, loadstring, loadfile, dofile and io module. I had to rename a few functions in luau to make it work, and conditionally define LUA_API as you said. I am looking forward to integrating my debugger after fixing the above 😎 |
Beta Was this translation helpful? Give feedback.
-
I have gotten luasocket to compile and load, not yet been able to verify that it works. Lpeg unfortunately relies on the same setfenv for userdata as iolib did, so I'm kind of stuck on that one. I tried running some pure lua replacement for lpeg to get past it and run my server but it uses every possible trick and function in the 5.1 api. I'm pushing the boundaries here on whats expected to do with luau, but I want to run my server unit tests in a good debugger. |
Beta Was this translation helpful? Give feedback.
-
I have now completed my luau integration, debugger and all. It runs my game, passes all my tests, breaks on breakpoints and steps in code. But I have not and will not use it in a production capacity until I have been running it in development for a while, so I can't speak for crashes and things like that yet. The only things that are not working and seemingly cant be fixed are:
In my shim project I have added:
And a bunch of defines needed for compatibility. Most of these are the pure lua-5.1 implementation, but there are some rewrites here and there. Looking forward to debugging and profiling now 😎 |
Beta Was this translation helpful? Give feedback.
I have now completed my luau integration, debugger and all. It runs my game, passes all my tests, breaks on breakpoints and steps in code. But I have not and will not use it in a production capacity until I have been running it in development for a while, so I can't speak for crashes and things like that yet.
The only things that are not working and seemingly cant be fixed are:
string.dump
setfenv
for userdata, used by lpeg and maybe others (cant use lpeg without rewriting things)__gc
in libs has to be rewritten tolua_newuserdatactor
or care has to be taken to close files/sockets etcIn my shim project I have added:
dofile
load
loadstring
require
module
debug.getfenv
debug.g…