mirror of https://github.com/bjornbytes/lovr.git
Allow absent main.lua;
This commit is contained in:
parent
dad98a3f75
commit
49297ba59b
|
@ -89,7 +89,7 @@ void lovrRun(lua_State* L, char* root) {
|
|||
}
|
||||
|
||||
// Run "main.lua" which will override/define pieces of lovr
|
||||
if (luaL_dofile(L, path)) {
|
||||
if (fileExists(path) && luaL_dofile(L, path)) {
|
||||
error("Failed to run main.lua");
|
||||
lua_pop(L, 1);
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
|
@ -19,6 +19,10 @@ void error(const char* format, ...) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int fileExists(char* filename) {
|
||||
return access(filename, F_OK) != -1;
|
||||
}
|
||||
|
||||
char* loadFile(char* filename) {
|
||||
struct stat info;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <lualib.h>
|
||||
|
||||
void error(const char* format, ...);
|
||||
int fileExists(char* filename);
|
||||
char* loadFile(char* filename);
|
||||
void luaRegisterModule(lua_State* L, const char* name, const luaL_Reg* module);
|
||||
void luaRegisterType(lua_State* L, const char* name, const luaL_Reg* functions, lua_CFunction gc);
|
||||
|
|
Loading…
Reference in New Issue