diff options
-rw-r--r-- | engines/hdb/lua-script.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp index 2fe55209ad..ab8d7ef16a 100644 --- a/engines/hdb/lua-script.cpp +++ b/engines/hdb/lua-script.cpp @@ -1215,6 +1215,8 @@ static int openFile(lua_State *L) { if (!outLua) error("Cannot open %s", fName); lua_pushlightuserdata(L, outLua); + } else { + error("LUA openFile: Unsupported mode '%s'", mode); } return 1; @@ -1229,7 +1231,6 @@ static int write(lua_State *L) { lua_pop(L, 2); out->write(data, strlen(data)); - debugN(3, "%s", data); return 0; } @@ -1248,6 +1249,23 @@ static int closeFile(lua_State *L) { return 0; } +static int dofile(lua_State *L) { + const char *fName = lua_tostring(L, 1); + + g_hdb->_lua->checkParameters("dofile", 1); + + lua_pop(L, 1); + + Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fName); + + if (!in) + error("Lua dofile: cannot open file '%s'", fName); + + delete in; + + return 0; +} + /* Lua Initialization Code */ @@ -1549,8 +1567,9 @@ struct FuncInit { { "Cine_PlayVoice", cinePlayVoice }, { "openfile", openFile, }, - { "write", write, }, + { "write", write, }, { "closefile", closeFile, }, + { "dofile", dofile, }, { NULL, NULL } }; |