From 6e8ef86afc5a559ff4df7f43bec53f82a9060731 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Wed, 3 Oct 2018 17:46:45 -0400 Subject: Allow brokengine to start projects in other directories Allow the second argument passed to brokengine on the command line specify the location of the data/ folder the program uses. --- src/client/initdevice.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/client/initdevice.cpp') diff --git a/src/client/initdevice.cpp b/src/client/initdevice.cpp index 79b6706..c7535a0 100644 --- a/src/client/initdevice.cpp +++ b/src/client/initdevice.cpp @@ -173,14 +173,18 @@ void settingsFromTable(lua_State *L, SIrrlichtCreationParameters* p){ printf("[OK]\n"); } -IrrlichtDevice* spawnIrrDevice(lua_State* L){ +IrrlichtDevice* spawnIrrDevice(lua_State* L, char *path){ //printf("Attempting to load settings...\n"); - int iErr = luaL_dofile(L,"../data/deviceinit.lua"); + char initname[] = "deviceinit.lua"; + size_t pathlen = strlen(initname) + strlen(path); + char filename[pathlen + 1]; + sprintf(filename,"%s/%s",path,initname); + int iErr = luaL_dofile(L,filename); SIrrlichtCreationParameters p = SIrrlichtCreationParameters(); - settingsFromTable(L,&p); if(iErr != 0){ - printf("Failed to open lua file:/data/deviceinit.lua\n"); + printf("Failed to open lua file:%s\n", filename); } + settingsFromTable(L,&p); IrrlichtDevice* dev = createDeviceEx(p); if(!dev) exit(1); -- cgit v1.2.3-70-g09d2