Created
February 29, 2012 07:02
-
-
Save ennorehling/1938692 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void register_loader(lua_State * L, const char * files_dir) { | |
char custom_path[PATH_MAX+1]; | |
lua_getglobal(L, "package"); | |
lua_getfield(L, -1, "loaders"); | |
int num_loaders = lua_objlen(L, -1); | |
lua_pushcfunction(L, asset_loader); | |
lua_rawseti(L, -2, 2); | |
lua_pop(L, 1); | |
lua_getfield(L, -1, "path"); | |
custom_path[0] = ';'; | |
strcpy(custom_path+1, files_dir); | |
strcat(custom_path, "/?.lua"); | |
lua_pushstring(L, custom_path); | |
lua_concat(L, 2); | |
lua_setfield(L, -2, "path"); | |
lua_pop(L, 1); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment