aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua_api.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lua_api.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lua_api.c b/src/lua_api.c
index ef5bf9a..8314e2a 100644
--- a/src/lua_api.c
+++ b/src/lua_api.c
@@ -33,7 +33,7 @@ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static bool debug_mode = false;
// -- script execution --
-void lua_load_script(lua_State *L, const char *script) {
+void lua_load_script(lua_State *L, const char *script, char **args) {
char script_path[512];
// check if script is in the current directory
if (access(script, F_OK) == 0) {
@@ -55,6 +55,16 @@ void lua_load_script(lua_State *L, const char *script) {
return;
}
}
+ // add args global if args were passed
+ if (args[0] != NULL) {
+ lua_newtable(L);
+ for (int i = 0; args[i]; i++) {
+ lua_pushstring(L, args[i]);
+ // i + 1 since Lua is 1 based indexed
+ lua_rawseti(L, -2, i + 1);
+ }
+ lua_setglobal(L, "args");
+ }
// if we got here the file exists
if (luaL_dofile(L, script_path) != LUA_OK) {
printf("[C] Error reading script\n");
pan class='insertions'>+34 2011-09-19change version to 'hg'Gravatar Connor Lane Smith 1-1/+1 2011-07-24dmenu_run: sh -cGravatar Connor Lane Smith 1-1/+1 2011-07-22fix loadfontGravatar Connor Lane Smith 1-12/+13 2011-07-19Added tag 4.4 for changeset 2b105eaae831Gravatar Connor Lane Smith 1-0/+1 2011-07-19add lsx.1 to distGravatar Connor Lane Smith 1-1/+1 2011-07-17tweaksGravatar Connor Lane Smith 2-2/+2 2011-07-14efficiency tweaksGravatar Connor Lane Smith 2-60/+44 2011-07-14fix extra warningGravatar Connor Lane Smith 1-1/+1 2011-07-06simpler vlineGravatar Connor Lane Smith 1-4/+2 2011-07-04rebind ^N ^PGravatar Connor Lane Smith 2-3/+3 2011-06-25include limits.hGravatar Connor Lane Smith 1-0/+1 2011-06-23make clean lsxGravatar Connor Lane Smith 1-1/+1 2011-06-23lsx: check snprintfGravatar Connor Lane Smith 1-4/+3 2011-06-18update draw.cGravatar Connor Lane Smith 2-14/+14 2011-06-18simpler lsxGravatar Connor Lane Smith 3-11/+6 2011-06-13new dmenu_runGravatar Connor Lane Smith 5-26/+15