![]() |
naev 0.12.5
|
Time manipulation Lua bindings. More...
#include "nlua_time.h"#include "nluadef.h"#include "ntime.h"
Go to the source code of this file.
Functions | |
| static int | timeL_new (lua_State *L) |
| Creates a time. This can be absolute or relative. | |
| static int | timeL_add (lua_State *L) |
| Adds two time metatables. | |
| static int | timeL_add__ (lua_State *L) |
| static int | timeL_sub (lua_State *L) |
| Subtracts two time metatables. | |
| static int | timeL_sub__ (lua_State *L) |
| static int | timeL_eq (lua_State *L) |
| Checks to see if two time are equal. | |
| static int | timeL_lt (lua_State *L) |
| Checks to see if a time is strictly larger than another. | |
| static int | timeL_le (lua_State *L) |
| Checks to see if a time is larger or equal to another. | |
| static int | timeL_get (lua_State *L) |
| Gets the current time in internal representation time. | |
| static int | timeL_str (lua_State *L) |
| Converts the time to a pretty human readable format. | |
| static int | timeL_inc (lua_State *L) |
| Increases or decreases the in-game time. | |
| static int | timeL_tonumber (lua_State *L) |
| Gets a number representing this time. | |
| static int | timeL_fromnumber (lua_State *L) |
| Creates a time from a number representing it. | |
| int | nlua_loadTime (nlua_env env) |
| Loads the Time Lua library. | |
| ntime_t * | lua_totime (lua_State *L, int ind) |
| Bindings for interacting with the time. | |
| ntime_t * | luaL_checktime (lua_State *L, int ind) |
| Gets time at index raising an error if isn't a time. | |
| ntime_t | luaL_validtime (lua_State *L, int ind) |
| Gets a time directly. | |
| ntime_t * | lua_pushtime (lua_State *L, ntime_t time) |
| Pushes a time on the stack. | |
| int | lua_istime (lua_State *L, int ind) |
| Checks to see if ind is a time. | |
Variables | |
| static const luaL_Reg | time_methods [] |
Time manipulation Lua bindings.
Definition in file nlua_time.c.
| int lua_istime | ( | lua_State * | L, |
| int | ind ) |
Checks to see if ind is a time.
| L | Lua state to check. |
| ind | Index position to check. |
Definition at line 138 of file nlua_time.c.
| ntime_t * lua_pushtime | ( | lua_State * | L, |
| ntime_t | time ) |
Pushes a time on the stack.
| L | Lua state to push time into. |
| time | Time to push. |
Definition at line 123 of file nlua_time.c.
| ntime_t * lua_totime | ( | lua_State * | L, |
| int | ind ) |
Bindings for interacting with the time.
Usage is generally something as follows:
Lua module: time
Gets time at index.
| L | Lua state to get time from. |
| ind | Index position to find the time. |
Definition at line 87 of file nlua_time.c.
| ntime_t * luaL_checktime | ( | lua_State * | L, |
| int | ind ) |
Gets time at index raising an error if isn't a time.
| L | Lua state to get time from. |
| ind | Index position to find the time. |
Definition at line 98 of file nlua_time.c.
| ntime_t luaL_validtime | ( | lua_State * | L, |
| int | ind ) |
Gets a time directly.
| L | Lua state to get time from. |
| ind | Index position to find the time. |
Definition at line 112 of file nlua_time.c.
| int nlua_loadTime | ( | nlua_env | env | ) |
Loads the Time Lua library.
| env | Lua environment. |
Definition at line 56 of file nlua_time.c.
|
static |
Adds two time metatables.
Overrides the addition operator.
Lua usage parameter: new_time = time.get() + time.new( 0, 5, 0 ) – Adds 5 periods to the current date Lua usage parameter: t:add( time.new( 0, 3, 0 ) ) – Directly modifies t
Lua function parameter: Time t1 Time metatable to add to. Lua function parameter: Time t2 Time metatable added.
| L | Lua State |
Lua function: add
Definition at line 192 of file nlua_time.c.
|
static |
Definition at line 208 of file nlua_time.c.
|
static |
Checks to see if two time are equal.
It is recommended to check with < and <= instead of ==.
Lua usage parameter: if time.new( 630, 5, 78) == time.get() then – do something if they match
Lua function parameter: Time t1 Time to compare for equality. Lua function parameter: Time t2 Time to compare for equality. Lua return parameter: boolean true if they're equal.
| L | Lua State |
Lua function: __eq
Definition at line 278 of file nlua_time.c.
|
static |
Creates a time from a number representing it.
The best usage for this currently is mission variables.
Lua usage parameter: t = time.fromnumber( t:tonumber() ) – Should get the time t again
Lua function parameter: number num Number to get time from. Lua return parameter: Time Time representing number.
| L | Lua State |
Lua function: fromnumber
Definition at line 417 of file nlua_time.c.
|
static |
Gets the current time in internal representation time.
Lua usage parameter: t = time.get()
Lua return parameter: Time Time in internal representation time.
| L | Lua State |
Lua function: get
Definition at line 332 of file nlua_time.c.
|
static |
Increases or decreases the in-game time.
Note that this can trigger hooks and fail missions and the likes.
Lua usage parameter: time.inc( time.new(0,0,100) ) – Increments the time by 100 seconds.
Lua function parameter: Time t Amount to increment or decrement the time by.
| L | Lua State |
Lua function: inc
Definition at line 382 of file nlua_time.c.
|
static |
Checks to see if a time is larger or equal to another.
Lua usage parameter: if time.new( 630, 5, 78) <= time.get() then – do something if time is past UST 630:0005.78
Lua function parameter: Time t1 Time to see if is is smaller or equal to than t2. Lua function parameter: Time t2 Time see if is larger or equal to than t1. Lua return parameter: boolean true if t1 <= t2
| L | Lua State |
Lua function: __le
Definition at line 316 of file nlua_time.c.
|
static |
Checks to see if a time is strictly larger than another.
Lua usage parameter: if time.new( 630, 5, 78) < time.get() then – do something if time is past UST 630:0005.78
Lua function parameter: Time t1 Time to see if is is smaller than t2. Lua function parameter: Time t2 Time see if is larger than t1. Lua return parameter: boolean true if t1 < t2
| L | Lua State |
Lua function: __lt
Definition at line 297 of file nlua_time.c.
|
static |
Creates a time. This can be absolute or relative.
Lua usage parameter: t = time.new( 591, 3271, 12801 ) – Gets a time near when the incident happened.
Lua function parameter: number cycles Cycles for the new time. Lua function parameter: number periods Periods for the new time. Lua function parameter: number seconds Seconds for the new time. Lua return parameter: Time A newly created time metatable.
| L | Lua State |
Lua function: new
Definition at line 166 of file nlua_time.c.
|
static |
Converts the time to a pretty human readable format.
Lua usage parameter: strt = time.str() – Gets current time Lua usage parameter: strt = time.str( nil, 5 ) – Gets current time with full decimals Lua usage parameter: strt = time.str( time.get() + time.new(0,5,0) ) – Gets time in 5 periods Lua usage parameter: strt = t:str() – Gets the string of t
Lua function parameter: Time t Time to convert to pretty format. If omitted, current time is used. Lua function parameter:[opt=2] number d Decimals to use for displaying seconds (should be between 0 and 5). Lua return parameter: string The time in human readable format.
| L | Lua State |
Lua function: str
Definition at line 353 of file nlua_time.c.
|
static |
Subtracts two time metatables.
Overrides the subtraction operator.
Lua usage parameter: new_time = time.get() - time.new( 0, 3, 0 ) – Subtracts 3 periods from the current date Lua usage parameter: t:sub( time.new( 0, 3, 0 ) ) – Directly modifies t
Lua function parameter: Time t1 Time metatable to subtract from. Lua function parameter: Time t2 Time metatable subtracted.
| L | Lua State |
Lua function: sub
Definition at line 235 of file nlua_time.c.
|
static |
Definition at line 251 of file nlua_time.c.
|
static |
Gets a number representing this time.
The best usage for this currently is mission variables.
Lua usage parameter: num = t:tonumber() – Getting the number from a time t
Lua function parameter: Time t Time to get number of. Lua return parameter: number Number representing time.
| L | Lua State |
Lua function: tonumber
Definition at line 399 of file nlua_time.c.
|
static |
Time Lua methods.
Definition at line 34 of file nlua_time.c.