r443 - trunk
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sun Jan 20 03:59:43 EST 2008
Author: icculus
Date: 2008-01-20 03:59:43 -0500 (Sun, 20 Jan 2008)
New Revision: 443
Modified:
trunk/lua_glue.c
trunk/lua_glue.h
Log:
Let you run Lua scripts from specific directories...
Modified: trunk/lua_glue.c
===================================================================
--- trunk/lua_glue.c 2008-01-20 08:53:39 UTC (rev 442)
+++ trunk/lua_glue.c 2008-01-20 08:59:43 UTC (rev 443)
@@ -376,13 +376,13 @@
} // MojoLua_callProcedure
-boolean MojoLua_runFile(const char *name)
+boolean MojoLua_runFileFromDir(const char *dir, const char *name)
{
MojoArchive *ar = GBaseArchive; // in case we want to generalize later.
const MojoArchiveEntry *entinfo;
boolean retval = false;
- char *clua = format("scripts/%0.luac", name); // compiled filename.
- char *ulua = format("scripts/%0.lua", name); // uncompiled filename.
+ char *clua = format("%0/%1.luac", dir, name); // compiled filename.
+ char *ulua = format("%0/%1.lua", dir, name); // uncompiled filename.
int rc = 0;
MojoInput *io = NULL;
@@ -432,6 +432,12 @@
} // if
return retval;
+} // MojoLua_runFileFromDir
+
+
+boolean MojoLua_runFile(const char *name)
+{
+ return MojoLua_runFileFromDir("scripts", name);
} // MojoLua_runFile
Modified: trunk/lua_glue.h
===================================================================
--- trunk/lua_glue.h 2008-01-20 08:53:39 UTC (rev 442)
+++ trunk/lua_glue.h 2008-01-20 08:59:43 UTC (rev 443)
@@ -27,13 +27,16 @@
boolean MojoLua_initialized(void);
// Run the code in a given Lua file. This is JUST the base filename.
-// We will look for it in GBaseArchive in the scripts/ directory, both as
+// We will look for it in GBaseArchive in the (dir) directory, both as
// fname.luac and fname.lua. This code chunk will accept no arguments, and
// return no results, but it can change the global state and alter tables,
// etc, so it can have lasting side effects.
// Will return false if the file couldn't be loaded, or true if the chunk
// successfully ran. Will not return if there's a runtime error in the
// chunk, as it will call fatal() instead.
+boolean MojoLua_runFileFromDir(const char *dir, const char *name)
+
+// This is shorthand for MojoLua_runFileFromDir("scripts", fname);
boolean MojoLua_runFile(const char *fname);
// Call a function in Lua. This calls MojoSetup.funcname, if it exists and
More information about the mojosetup-commits
mailing list