From 65252aa0028817da65ff193fb06f175c0a7b0c1b Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 30 May 2011 16:45:39 +0100 Subject: [PATCH] drawtext for Lua --- includes/luaconsole.h | 1 + src/luaconsole.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/includes/luaconsole.h b/includes/luaconsole.h index c8b6b1958..ddcac43a1 100644 --- a/includes/luaconsole.h +++ b/includes/luaconsole.h @@ -14,4 +14,5 @@ int process_command_lua(pixel *vid_buf, char *console, char *console_error); //TPT Interface int luatpt_test(lua_State* l); +int luatpt_drawtext(lua_State* l); #endif diff --git a/src/luaconsole.c b/src/luaconsole.c index 4c216137f..7e3403cd9 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -5,10 +5,10 @@ lua_State *l; void luacon_open(){ const static struct luaL_reg tptluaapi [] = { {"test", &luatpt_test}, + {"drawtext", &luatpt_drawtext}, {NULL,NULL} }; - l = lua_open(); luaL_openlibs(l); luaL_openlib(l, "tpt", tptluaapi, 0); @@ -57,5 +57,22 @@ int luatpt_test(lua_State* l) printf("Test successful, got %d\n", testint); return 1; } +int luatpt_drawtext(lua_State* l) +{ + char *string; + int textx, texty, textred, textgreen, textblue, textalpha; + textx = luaL_optint(l, 1, 0); + texty = luaL_optint(l, 2, 0); + string = luaL_optstring(l, 3, 0); + textred = luaL_optint(l, 4, 0); + textgreen = luaL_optint(l, 5, 0); + textblue = luaL_optint(l, 6, 0); + textalpha = luaL_optint(l, 7, 0); + if(vid_buf!=NULL){ + drawtext(vid_buf, textx, texty, string, textred, textgreen, textblue, textalpha); + return 0; + } + return -1; +} #endif