C# Class GarrysModLuaShared.timer

The timer library is a very useful set of functions which allow you to run a function periodically or after a given delay.
ファイルを表示 Open project: OmegaExtern/gmod-csharp-binary-module

Public Methods

Method Description
Adjust ( LuaState luaState, object identifier, double delay, uint repetitions, lua_CFunction function ) : bool

Adjusts the timer if the timer with the given identifier exists.

Create ( LuaState luaState, object identifier, double delay, uint repetitions, lua_CFunction function ) : void

Creates a new timer.

Exists ( LuaState luaState, object identifier ) : bool

Returns whenever the given timer exists or not.

Pause ( LuaState luaState, object identifier ) : bool

Pauses the given timer.

Remove ( LuaState luaState, object identifier ) : void

Stops and removes the timer.

RepsLeft ( LuaState luaState, object identifier ) : uint

Returns amount of repetitions/executions left before the timer destroys itself.

Simple ( LuaState luaState, double delay, lua_CFunction function ) : void

Runs the given function after a specified delay.

Start ( LuaState luaState, object identifier ) : bool

Restarts the given timer.

Stop ( LuaState luaState, object identifier ) : bool

Stops the given timer.

TimeLeft ( LuaState luaState, object identifier ) : double

Returns amount of time left before the timer executes its function. If the timer is paused, the amount will be negative.

Toggle ( LuaState luaState, object identifier ) : bool

Runs either Pause or UnPause based on the timer's current status.

UnPause ( LuaState luaState, object identifier ) : bool

Unpauses the timer.

Method Details

Adjust() public static method

Adjusts the timer if the timer with the given identifier exists.
public static Adjust ( LuaState luaState, object identifier, double delay, uint repetitions, lua_CFunction function ) : bool
luaState LuaState Pointer to lua_State struct.
identifier object Identifier of the timer to adjust.
delay double The delay interval in seconds.
repetitions uint Repetitions. Use 0 for infinite.
function lua_CFunction The new function.
return bool

Create() public static method

Creates a new timer.
public static Create ( LuaState luaState, object identifier, double delay, uint repetitions, lua_CFunction function ) : void
luaState LuaState Pointer to lua_State struct.
identifier object Identifier of the timer to adjust.
delay double The delay interval in seconds.
repetitions uint The number of times to repeat the timer (use 0 for infinite repetitions).
function lua_CFunction Function to call when timer has finished the countdown.
return void

Exists() public static method

Returns whenever the given timer exists or not.
public static Exists ( LuaState luaState, object identifier ) : bool
luaState LuaState Pointer to lua_State struct.
identifier object Identifier of the timer.
return bool

Pause() public static method

Pauses the given timer.
public static Pause ( LuaState luaState, object identifier ) : bool
luaState LuaState Pointer to lua_State struct.
identifier object Identifier of the timer.
return bool

Remove() public static method

Stops and removes the timer.
public static Remove ( LuaState luaState, object identifier ) : void
luaState LuaState Pointer to lua_State struct.
identifier object Identifier of the timer to remove.
return void

RepsLeft() public static method

Returns amount of repetitions/executions left before the timer destroys itself.
public static RepsLeft ( LuaState luaState, object identifier ) : uint
luaState LuaState Pointer to lua_State struct.
identifier object Identifier of the timer.
return uint

Simple() public static method

Runs the given function after a specified delay.
public static Simple ( LuaState luaState, double delay, lua_CFunction function ) : void
luaState LuaState Pointer to lua_State struct.
delay double How long until the function should be ran (in seconds).
function lua_CFunction The function to run after the specified delay.
return void

Start() public static method

Restarts the given timer.
public static Start ( LuaState luaState, object identifier ) : bool
luaState LuaState Pointer to lua_State struct.
identifier object Identifier of the timer.
return bool

Stop() public static method

Stops the given timer.
public static Stop ( LuaState luaState, object identifier ) : bool
luaState LuaState Pointer to lua_State struct.
identifier object Identifier of the timer.
return bool

TimeLeft() public static method

Returns amount of time left before the timer executes its function. If the timer is paused, the amount will be negative.
public static TimeLeft ( LuaState luaState, object identifier ) : double
luaState LuaState Pointer to lua_State struct.
identifier object Identifier of the timer.
return double

Toggle() public static method

Runs either Pause or UnPause based on the timer's current status.
public static Toggle ( LuaState luaState, object identifier ) : bool
luaState LuaState Pointer to lua_State struct.
identifier object Identifier of the timer.
return bool

UnPause() public static method

Unpauses the timer.
public static UnPause ( LuaState luaState, object identifier ) : bool
luaState LuaState Pointer to lua_State struct.
identifier object Identifier of the timer.
return bool