Step code registration, just an example at the moment
This commit is contained in:
parent
d5f1a4cfd0
commit
b0659e3dd1
12
build/test.lua
Normal file
12
build/test.lua
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
tpt.register_step("do_step")
|
||||||
|
numberthing = 0
|
||||||
|
increment = 2
|
||||||
|
function do_step()
|
||||||
|
numberthing = numberthing + increment;
|
||||||
|
if numberthing >= 400 then
|
||||||
|
increment = -2
|
||||||
|
elseif numberthing < 4 then
|
||||||
|
increment = 2
|
||||||
|
end
|
||||||
|
tpt.drawtext(numberthing, 50, "Oh my god, this is amazing", 255, 255, 255, 255)
|
||||||
|
end
|
@ -33,4 +33,5 @@ int luatpt_textwidth(lua_State* l);
|
|||||||
int luatpt_get_name(lua_State* l);
|
int luatpt_get_name(lua_State* l);
|
||||||
int luatpt_set_shortcuts(lua_State* l);
|
int luatpt_set_shortcuts(lua_State* l);
|
||||||
int luatpt_delete(lua_State* l);
|
int luatpt_delete(lua_State* l);
|
||||||
|
int luatpt_register_step(lua_State* l);
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <luaconsole.h>
|
#include <luaconsole.h>
|
||||||
|
|
||||||
lua_State *l;
|
lua_State *l;
|
||||||
|
char *step_function = "";
|
||||||
void luacon_open(){
|
void luacon_open(){
|
||||||
const static struct luaL_reg tptluaapi [] = {
|
const static struct luaL_reg tptluaapi [] = {
|
||||||
{"test", &luatpt_test},
|
{"test", &luatpt_test},
|
||||||
@ -25,6 +26,7 @@ void luacon_open(){
|
|||||||
{"get_name", &luatpt_get_name},
|
{"get_name", &luatpt_get_name},
|
||||||
{"set_shortcuts", &luatpt_set_shortcuts},
|
{"set_shortcuts", &luatpt_set_shortcuts},
|
||||||
{"delete", &luatpt_delete},
|
{"delete", &luatpt_delete},
|
||||||
|
{"register_step", &luatpt_register_step},
|
||||||
{NULL,NULL}
|
{NULL,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -33,7 +35,10 @@ void luacon_open(){
|
|||||||
luaL_openlib(l, "tpt", tptluaapi, 0);
|
luaL_openlib(l, "tpt", tptluaapi, 0);
|
||||||
}
|
}
|
||||||
int luacon_step(){
|
int luacon_step(){
|
||||||
//Nothing here yet
|
if(step_function && step_function[0]){
|
||||||
|
lua_getfield(l, LUA_GLOBALSINDEX, step_function);
|
||||||
|
lua_call(l, 0, 0);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int luacon_keypress(char key){
|
int luacon_keypress(char key){
|
||||||
@ -368,4 +373,10 @@ int luatpt_delete(lua_State* l)
|
|||||||
//TODO: Implement luatpt_delete (Delete particle)
|
//TODO: Implement luatpt_delete (Delete particle)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int luatpt_register_step(lua_State* l)
|
||||||
|
{
|
||||||
|
step_function = luaL_optstring(l, 1, "");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user