Original Post
🔒 Locked
Integrating LUA + PhysFS
Advertisement
I did some investigation into this a while back, I don't have my notes on me atm as I'm at work, however I seem to recall that there are a couple of table entries which you can replace which are responcible for loading things in.
I'll see if I can find my notes when I get home.. (having moved house recently I'm not as sure as I once was about the location of such things, heh)
I'll see if I can find my notes when I get home.. (having moved house recently I'm not as sure as I once was about the location of such things, heh)
Progress report:
I rewrote luaL_loadfile (lauxlib.c) to use PHYSFS, so dofile already works correctly except if a unix shebang line is included (PHYSFS is unbuffered by default and thus I can't put back the last char, although I could do a tell, followed by a seek), but these wouldn't make much sense in this context anyways imo. I might also remove the ability to dofile from stdin (again, makes little sense in this context)
I also changed print (lbaselib.c) to use c++ cout instead of c stdout, because this way I can redirect to any c++ buffer, for example to an ingame console or similar.
The way I see it right now I will have to exclude the package lib, because loading dll/so files through a VFS won't work. (Besides, allowing to load arbitrary lua dll modules, could circumvent the "Sandbox" created by using PhysFS) Too bad "require" will be lost due to this. Maybe I could reimplement require but for .lua and .lub files only.
Rewriting the io lib would be a *lot* of work, but it should be possible. But an easier solution would be nice.
I rewrote luaL_loadfile (lauxlib.c) to use PHYSFS, so dofile already works correctly except if a unix shebang line is included (PHYSFS is unbuffered by default and thus I can't put back the last char, although I could do a tell, followed by a seek), but these wouldn't make much sense in this context anyways imo. I might also remove the ability to dofile from stdin (again, makes little sense in this context)
I also changed print (lbaselib.c) to use c++ cout instead of c stdout, because this way I can redirect to any c++ buffer, for example to an ingame console or similar.
The way I see it right now I will have to exclude the package lib, because loading dll/so files through a VFS won't work. (Besides, allowing to load arbitrary lua dll modules, could circumvent the "Sandbox" created by using PhysFS) Too bad "require" will be lost due to this. Maybe I could reimplement require but for .lua and .lub files only.
Rewriting the io lib would be a *lot* of work, but it should be possible. But an easier solution would be nice.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement