25static int timeL_add__( lua_State *L );
27static int timeL_sub__( lua_State *L );
38 {
"add", timeL_add__ },
40 {
"sub", timeL_sub__ },
92 return (ntime_t*) lua_touserdata(L,ind);
105 luaL_typerror(L, ind, TIME_METATABLE);
128 ntime_t *p = (ntime_t*) lua_newuserdata(L,
sizeof(ntime_t));
130 luaL_getmetatable(L, TIME_METATABLE);
131 lua_setmetatable(L, -2);
145 if (lua_getmetatable(L,ind)==0)
147 lua_getfield(L, LUA_REGISTRYINDEX, TIME_METATABLE);
150 if (lua_rawequal(L, -1, -2))
170 int cycles, periods, seconds;
173 cycles = luaL_checkint(L,1);
174 periods = luaL_checkint(L,2);
175 seconds = luaL_checkint(L,3);
208static int timeL_add__( lua_State *L )
249static int timeL_sub__( lua_State *L )
280 lua_pushboolean( L, t1==t2 );
298 lua_pushboolean( L, t1<t2 );
316 lua_pushboolean( L, t1<=t2 );
352 if (!lua_isnoneornil(L,1))
356 d = luaL_optinteger(L,2,2);
360 lua_pushstring(L, nt);
394 lua_pushnumber( L, t );
411 ntime_t t = (ntime_t) luaL_checknumber(L,1);
Header file with generic functions and naev-specifics.
static int timeL_sub(lua_State *L)
Subtracts two time metatables.
static int timeL_lt(lua_State *L)
Checks to see if a time is strictly larger than another.
ntime_t * luaL_checktime(lua_State *L, int ind)
Gets time at index raising an error if isn't a time.
ntime_t * lua_pushtime(lua_State *L, ntime_t time)
Pushes a time on the stack.
int nlua_loadTime(nlua_env env)
Loads the Time Lua library.
int lua_istime(lua_State *L, int ind)
Checks to see if ind is a time.
static int timeL_le(lua_State *L)
Checks to see if a time is larger or equal to another.
static int timeL_tonumber(lua_State *L)
Gets a number representing this time.
static int timeL_add(lua_State *L)
Adds two time metatables.
static int timeL_fromnumber(lua_State *L)
Creates a time from a number representing it.
static int timeL_new(lua_State *L)
Creates a time. This can be absolute or relative.
static const luaL_Reg time_methods[]
static int timeL_inc(lua_State *L)
Increases or decreases the in-game time.
static int timeL_eq(lua_State *L)
Checks to see if two time are equal.
static int timeL_str(lua_State *L)
Converts the time to a pretty human readable format.
ntime_t luaL_validtime(lua_State *L, int ind)
Gets a time directly.
static int timeL_get(lua_State *L)
Gets the current time in internal representation time.
ntime_t * lua_totime(lua_State *L, int ind)
Bindings for interacting with the time.
ntime_t ntime_create(int scu, int stp, int stu)
Creates a time structure.
ntime_t ntime_get(void)
Gets the current time.
void ntime_inc(ntime_t t)
Sets the time relatively.
void ntime_prettyBuf(char *str, int max, ntime_t t, int d)
Gets the time in a pretty human readable format filling a preset buffer.