Game (functions)/Utils
This page documents the ScriptGame class for Lua scripting.
As a singleton class, it can be accessed from Lua with GAME.
IsKeyDown
GAME:IsKeyDown(keyid)
Checks if a player is making a certain physical keyboard input.
Parameters
| Name | Type | Description |
|---|---|---|
| System.Int32 | System.Int32 | The ID of the input |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the button is currently pressed. False otherwise. |
IsInputDown
GAME:IsInputDown(inputid)
Checks if a player is making a certain game input.
Parameters
| Name | Type | Description |
|---|---|---|
| System.Int32 | System.Int32 |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the input is currently pressed. False otherwise. |
QueueLeaderEvent
GAME:QueueLeaderEvent(obj)
Prepares an event to execute on the next frame.
Parameters
| Name | Type | Description |
|---|---|---|
| System.Object | System.Object |
WaitFrames
GAME:WaitFrames(frames)
Waits for a specified number of frames before continuing.
Parameters
| Name | Type | Description |
|---|---|---|
| System.Int32 | System.Int32 | The number of frames to wait. Each frame is 1/60th of a second. |
Returns
| Type | Description |
|---|---|
| NLua.LuaFunction |
VectorToDirection
GAME:VectorToDirection(v)
Turns a vector (preferably a unit vector) into a cardinal or diagonal direction.
Parameters
| Name | Type | Description |
|---|---|---|
| RogueElements.Loc | RogueElements.Loc | The vector. |
Returns
| Type | Description |
|---|---|
| RogueElements.Dir8 | The direction as one of 8 values. |
VectorToDirection
GAME:VectorToDirection(X, Y)
Convenience function to get a vector's components from lua numbers(doubles)
Parameters
| Name | Type | Description |
|---|---|---|
| System.Double | System.Double | The X value of the vector |
| System.Double | System.Double | The Y value of the vector |
Returns
| Type | Description |
|---|---|
| RogueElements.Dir8 | The direction the vector points to as one of 8 values. |
RandomDirection
GAME:RandomDirection()
Generates a random direction.
Returns
| Type | Description |
|---|---|
| RogueElements.Dir8 | An 8-directional direction. |
References
https://github.com/RogueCollab/RogueEssence/blob/master/RogueEssence/Lua/ScriptGameUtils.cs
