diff --git a/apps/twnlua/game.c b/apps/twnlua/game.c index 6b091b3..1e2a530 100644 --- a/apps/twnlua/game.c +++ b/apps/twnlua/game.c @@ -14,10 +14,19 @@ void bindgen_upload_context(lua_State *L); /* require will go through physicsfs exclusively so that scripts can be in the data dir */ /* TODO: allow for bytecode files */ +/* TODO: support .lua suffixes files? */ static int physfs_loader(lua_State *L) { const char *name = luaL_checkstring(L, 1); + + /* replace dots with path slashes */ + char *path_copy = SDL_strdup(name); + char *ch = NULL; + while ((ch = SDL_strchr(path_copy, '.'))) + *ch = '/'; + char *final_path = NULL; - SDL_asprintf(&final_path, "/scripts/%s.lua", name); + SDL_asprintf(&final_path, "/scripts/%s.lua", path_copy); + SDL_free(path_copy); if (!file_exists(final_path)) { char *error_message = NULL;