aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/initdevice.cpp12
-rw-r--r--src/client/initdevice.hpp2
-rw-r--r--src/client/main.cpp13
3 files changed, 19 insertions, 8 deletions
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);
diff --git a/src/client/initdevice.hpp b/src/client/initdevice.hpp
index dd328f7..0a65a99 100644
--- a/src/client/initdevice.hpp
+++ b/src/client/initdevice.hpp
@@ -13,5 +13,5 @@ using namespace video;
using namespace io;
using namespace gui;
-IrrlichtDevice* spawnIrrDevice(lua_State* L);
+IrrlichtDevice* spawnIrrDevice(lua_State* L, char *path);
#endif
diff --git a/src/client/main.cpp b/src/client/main.cpp
index 63b7131..4885d8a 100644
--- a/src/client/main.cpp
+++ b/src/client/main.cpp
@@ -122,12 +122,19 @@ int main(int argc, char *argv[]){
//Load the lua libraries
loadLLibs(state);
//Defined in initdevice.cpp, creates the irrlicht device
- device = spawnIrrDevice(state);
+ printf("Argc: %d\n",argc);
+ char *path;
+ if(argc == 2){
+ path = argv[1];
+ }else{
+ path = (char*)"../data";
+ }
+ device = spawnIrrDevice(state,path);
if (!device){
printf("Failed to initalize device\n");
return 1;
}
- device->getFileSystem()->changeWorkingDirectoryTo("../data");
+ device->getFileSystem()->changeWorkingDirectoryTo(path);
//ILogger* log = device->getLogger();
//log->setLogLevel(ELL_NONE);
//Loads libraries for interfaceing with irrlicht
@@ -198,6 +205,6 @@ int main(int argc, char *argv[]){
phys_shutdown(RemoveISceneNode);
device->drop();
-
+ printf("Goodbye\n");
return 0;
}