diff --git a/ag.cc b/ag.cc index ed6a630..87cd4ad 100644 --- a/ag.cc +++ b/ag.cc @@ -3,6 +3,7 @@ #include "ag.h" #include "Video.h" #include "wfobj/WFObj.hh" +#include /* usleep() */ #include #include #include @@ -18,6 +19,7 @@ namespace ag { "loadModel", loadModel }, { "videoStart", videoStart }, { "videoStop", videoStop }, + { "sleep", sleep }, { NULL, NULL } }; luaL_register(L, "ag", functions); @@ -115,10 +117,28 @@ namespace ag int videoStart(lua_State * L) { g_video->start(); + return 0; } int videoStop(lua_State * L) { g_video->stop(); + return 0; + } + + int sleep(lua_State * L) + { + int argc = lua_gettop(L); + + if (argc == 1) + { + if (lua_type(L, -1) == LUA_TNUMBER) + { + double seconds = lua_tonumber(L, -1); + usleep((useconds_t) (seconds * 1000000)); + } + } + + return 0; } } diff --git a/ag.h b/ag.h index 757c2f2..5d94c7f 100644 --- a/ag.h +++ b/ag.h @@ -12,6 +12,7 @@ namespace ag int loadModel(lua_State * L); int videoStart(lua_State * L); int videoStop(lua_State * L); + int sleep(lua_State * L); } #endif