blob: f7310dc8b70410a56077c0f6dc6399f7f5e0bbf2 (
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 "lua/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;
}
}
}
|