diff options
| author | Bryan Hoyle <starfoxprime@gmail.com> | 2011-08-25 15:14:27 (GMT) |
|---|---|---|
| committer | Bryan Hoyle <starfoxprime@gmail.com> | 2011-08-25 15:14:27 (GMT) |
| commit | 951a396e60e98440780acb3bb7d09350aa648e7b (patch) | |
| tree | 7db8a819e54d75100ea96ac668d2fa580fe89491 /src | |
| parent | a2ce9d6db7530909a3d2f5d1fb0a8ebaa9e60609 (diff) | |
| download | powder-951a396e60e98440780acb3bb7d09350aa648e7b.zip powder-951a396e60e98440780acb3bb7d09350aa648e7b.tar.gz | |
Added autorun option to tpt.getscript()
Diffstat (limited to 'src')
| -rw-r--r-- | src/luaconsole.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/luaconsole.c b/src/luaconsole.c index 2071e42..adf4620 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -1072,12 +1072,13 @@ return 0; } int luatpt_getscript(lua_State* l) { - char *fileid = NULL, *filedata = NULL, *fileuri = NULL, *fileauthor = NULL, *filename = NULL, *lastError = NULL; - int len, ret; + char *fileid = NULL, *filedata = NULL, *fileuri = NULL, *fileauthor = NULL, *filename = NULL, *lastError = NULL, *luacommand = NULL; + int len, ret,run_script; FILE * outputfile; fileauthor = mystrdup(luaL_optstring(l, 1, "")); fileid = mystrdup(luaL_optstring(l, 2, "")); + run_script = luaL_optint(l, 3, 0); if(!fileauthor || !fileid || strlen(fileauthor)<1 || strlen(fileid)<1) goto fin; if(!confirm_ui(vid_buf, "Do you want to install script?", fileid, "Install")) @@ -1133,16 +1134,25 @@ int luatpt_getscript(lua_State* l) goto fin; } + fputs(filedata, outputfile); fclose(outputfile); outputfile = NULL; - + if(run_script) + { + luacommand = malloc(strlen(filename)+20); + sprintf(luacommand,"dofile(\"%s\")",filename); + luacon_eval(luacommand); + } + fin: if(fileid) free(fileid); if(filedata) free(filedata); if(fileuri) free(fileuri); if(fileauthor) free(fileauthor); if(filename) free(filename); + if(luacommand) free(luacommand); + luacommand = NULL; if(lastError) return luaL_error(l, lastError); return 0; |
