Skip to main content
gamedev.net
🔒 Locked

Integrating LUA + PhysFS

Started by l0calh05t Jan 29, 2008 at 4:01 PM 1 replies 1.8k views
Original Post
l0calh05t
l0calh05t
Anyone done this yet? Will I have to do an almost complete rewrite of loadlib and lauxlib? Or is there any other way to replace the standard file access with physfs file access?
_the_phantom_
_the_phantom_
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)
l0calh05t
l0calh05t
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.