summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-10-21 16:37:26 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-10-21 16:37:26 (GMT)
commit08009ebbaac9abd7941f5057a2289cbbbde4c5ee (patch)
treecc7c1ce36e8b44fce15ff1f170e9fb00bb475758
parentc1eb40af61fc04a2db8971bbf233ddb0f9f4a2b5 (diff)
downloadpowder-08009ebbaac9abd7941f5057a2289cbbbde4c5ee.zip
powder-08009ebbaac9abd7941f5057a2289cbbbde4c5ee.tar.gz
Screenshot for lua
-rw-r--r--includes/luaconsole.h1
-rw-r--r--src/luaconsole.c25
2 files changed, 23 insertions, 3 deletions
diff --git a/includes/luaconsole.h b/includes/luaconsole.h
index dc320ad..de33a04 100644
--- a/includes/luaconsole.h
+++ b/includes/luaconsole.h
@@ -77,4 +77,5 @@ int luatpt_setdebug(lua_State* l);
int luatpt_setfpscap(lua_State* l);
int luatpt_getscript(lua_State* l);
int luatpt_setwindowsize(lua_State* l);
+int luatpt_screenshot(lua_State* l);
#endif
diff --git a/src/luaconsole.c b/src/luaconsole.c
index 5cc2bb3..c74155b 100644
--- a/src/luaconsole.c
+++ b/src/luaconsole.c
@@ -65,6 +65,7 @@ void luacon_open(){
{"getscript",&luatpt_getscript},
{"setwindowsize",&luatpt_setwindowsize},
{"watertest",&luatpt_togglewater},
+ {"screenshot",&luatpt_screenshot},
{NULL,NULL}
};
@@ -1123,9 +1124,9 @@ int luatpt_setdebug(lua_State* l)
}
int luatpt_setfpscap(lua_State* l)
{
-int fpscap = luaL_optint(l, 1, 0);
-limitFPS = fpscap;
-return 0;
+ int fpscap = luaL_optint(l, 1, 0);
+ limitFPS = fpscap;
+ return 0;
}
int luatpt_getscript(lua_State* l)
{
@@ -1225,4 +1226,22 @@ int luatpt_setwindowsize(lua_State* l)
return 1;
}
+int luatpt_screenshot(lua_State* l)
+{
+ int captureUI = luaL_optint(l, 1, 0);
+ if(vid_buf)
+ {
+ if(captureUI)
+ {
+ dump_frame(vid_buf, XRES+BARSIZE, YRES+MENUSIZE, XRES+BARSIZE);
+ }
+ else
+ {
+ dump_frame(vid_buf, XRES, YRES, XRES+BARSIZE);
+ }
+ return 0;
+ }
+ return luaL_error(l, "Screen buffer does not exist");
+}
+
#endif