summaryrefslogtreecommitdiff
path: root/Examples/lua/embed3/embed3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/lua/embed3/embed3.cpp')
-rw-r--r--Examples/lua/embed3/embed3.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/Examples/lua/embed3/embed3.cpp b/Examples/lua/embed3/embed3.cpp
index d559167d1..9be49add3 100644
--- a/Examples/lua/embed3/embed3.cpp
+++ b/Examples/lua/embed3/embed3.cpp
@@ -113,10 +113,14 @@ int main(int argc, char* argv[]) {
push_pointer(L,&engine,"Engine *",0);
lua_setglobal(L, "pEngine"); // set as global variable
- printf("[C++] now let's load the file 'runme.lua'\n");
+ if (argc != 2 || argv[1] == NULL || strlen(argv[1]) == 0) {
+ printf("[C++] ERROR: no lua file given on command line\n");
+ exit(3);
+ }
+ printf("[C++] now let's load the file '%s'\n", argv[1]);
printf("[C++] any lua code in this file will be executed\n");
- if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
- printf("[C++] ERROR: cannot run lua file: %s", lua_tostring(L, -1));
+ if (luaL_loadfile(L, argv[1]) || lua_pcall(L, 0, 0, 0)) {
+ printf("[C++] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
exit(3);
}
printf("[C++] We are now back in C++, all looks ok\n");