drawtext for Lua

This commit is contained in:
Simon Robertshaw 2011-05-30 16:45:39 +01:00
parent 79a27c2c90
commit 65252aa002
2 changed files with 19 additions and 1 deletions

View File

@ -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

View File

@ -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