22static int timeL_add__( lua_State *L );
24static int timeL_sub__( lua_State *L );
35 {
"add", timeL_add__ },
37 {
"sub", timeL_sub__ },
89 return (ntime_t *)lua_touserdata( L, ind );
102 luaL_typerror( L, ind, TIME_METATABLE );
125 ntime_t *p = (ntime_t *)lua_newuserdata( L,
sizeof( ntime_t ) );
127 luaL_getmetatable( L, TIME_METATABLE );
128 lua_setmetatable( L, -2 );
142 if ( lua_getmetatable( L, ind ) == 0 )
144 lua_getfield( L, LUA_REGISTRYINDEX, TIME_METATABLE );
147 if ( lua_rawequal( L, -1, -2 ) )
168 int cycles, periods, seconds;
171 cycles = luaL_checkint( L, 1 );
172 periods = luaL_checkint( L, 2 );
173 seconds = luaL_checkint( L, 3 );
208static int timeL_add__( lua_State *L )
251static int timeL_sub__( lua_State *L )
283 lua_pushboolean( L, t1 == t2 );
302 lua_pushboolean( L, t1 < t2 );
321 lua_pushboolean( L, t1 <= t2 );
360 if ( !lua_isnoneornil( L, 1 ) )
364 d = luaL_optinteger( L, 2, 2 );
368 lua_pushstring( L, nt );
402 lua_pushnumber( L, t );
419 ntime_t t = (ntime_t)luaL_checknumber( L, 1 );
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.