blob: a26be17d753e4758a4db0094fac3540cf36a5a4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "3rdparty/luax/luax.h"
#include <SDL2/SDL.h>
namespace jin
{
namespace lua
{
static int l_sec(lua_State* L)
{
luax_pushnumber(L, SDL_GetTicks()/1000.f);
return 1;
}
static int l_sleep(lua_State* L)
{
double sec = luax_checknumber(L, 1);
SDL_Delay(sec * 1000);
return 0;
}
static const luaL_Reg f[] = {
{"second", l_sec},
{"sleep", l_sleep},
{0, 0},
};
int luaopen_time(lua_State* L)
{
luax_newlib(L, f);
return 1;
}
}
}
|