added ag::sleep()
git-svn-id: svn://anubis/anaglym/trunk@22 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
6bb601355b
commit
8817201a27
20
ag.cc
20
ag.cc
@ -3,6 +3,7 @@
|
||||
#include "ag.h"
|
||||
#include "Video.h"
|
||||
#include "wfobj/WFObj.hh"
|
||||
#include <unistd.h> /* usleep() */
|
||||
#include <lua.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user