Skip to content

Game

Variables

deltaTime

Game.deltaTime

Returns a float with the real world time in seconds since the last frame.

Example
Game.deltaTime

GameState

Game.GameState

Variable holding the current Game State. Only accessible if the local player has unrestricted modding access (If player is Host or if the host has enabled unrestricted modding access for guests).

Example
Game.GameState

playerSaveSlot

Game.playerSaveSlot

Variable holding the player's current character save slot.

Example
Game.playerSaveSlot

worldSaveSlot

Game.worldSaveSlot

Variable holding the world's current save slot.

Example
Game.worldSaveSlot

Functions

IsHost

 function Game.IsHost()

Game.IsHost

Returns true if the local player is the host of the room.

Example
Game.IsHost()

IsOfflineMode

 function Game.IsOfflineMode()

Game.IsOfflineMode

Returns true if the game is being played in offline mode.

Example
Game.IsOfflineMode()

HasUnrestrictedModdingAccess

 function Game.HasUnrestrictedModdingAccess()

Game.HasUnrestrictedModdingAccess

Returns true if the local player is the host of the room or a if the room has unrestricted modding access for guests enabled.

Example
Game.HasUnrestrictedModdingAccess()

GetPlayerCount

 function Game.GetPlayerCount()

Game.GetPlayerCount

Returns the current number of players in the game

Example
Game.GetPlayerCount()

PauseGame

 function Game.PauseGame()

Game.PauseGame

Pauses the game and opens the pause menu

Example
Game.PauseGame()

UnpauseGame

 function Game.UnpauseGame()

Game.UnpauseGame

Unpauses the game and closes the pause menu

Example
Game.UnpauseGame()

PlayerReceiveItem

 function Game.PlayerReceiveItem((string)ItemID , (int)Amount, (optional bool)Alert)
Parameter Type 📝 Description
ItemID string Item ID
Amount int Amount of the item to drop
Alert optional bool If set to true a pickup alert will be displayed on the bottom left corner of the screen.

Game.PlayerReceiveItem

Makes the main player receive an amount of an item.

Example

Game.PlayerReceiveItem("daisy", 1)
This example will make the player receive a daisy.


CallGlobalFunction

 function Game.CallGlobalFunction((string)ID , (optional parameters)Optional Parameters)
Parameter Type 📝 Description
ID string Id of the function that should be called.
Optional Parameters optional parameters Other parameters to call this function with.

Game.CallGlobalFunction

Calls a function that has been registered by another script as a global function using self.RegisterGlobalFunction.

Example

Game.CallGlobalFunction("DoTest")
This example calls the global function 'DoTest'.


CallNextFrame

 function Game.CallNextFrame((function)Function , (parameters)Other Parameters)
Parameter Type 📝 Description
Function function Function to be called
Other Parameters parameters This method can be called with aditional parameters to be sent to the function to be called.

Game.CallNextFrame

Calls a function after one frame has passed.

Example

Game.CallNextFrame(TestFunction,"Test")
This example will call the function TestFunction with the parameter 'Test' in one frame.


DelayCall

 function Game.DelayCall((function)Function , (float)Delay, (parameters)Other Parameters)
Parameter Type 📝 Description
Function function Function to be called
Delay float Delay to wait before calling the function
Other Parameters parameters This method can be called with aditional parameters to be sent to the function to be called.

Game.DelayCall

Calls a function after a delay has passed.

Example

Game.DelayCall(TestFunction,2,"Test")
This example will call the function TestFunction with the parameter 'Test' in 2 seconds.


MakeRoomVisible

 function Game.MakeRoomVisible()

Game.MakeRoomVisible

Provided that Clock.CurrentTimeFromEver() is not zero and the player is the host of the room, it forces the room to be visible on the room listings.

Example
Game.MakeRoomVisible()

HasEvent

 function Game.HasEvent((string)EventID)
Parameter Type 📝 Description
EventID string Event Id

Game.HasEvent

Checks if the game has an event

Example

Game.HasEvent("test")
Checks if the game has an event with id 'test'


AddEvent

 function Game.AddEvent((string)EventID , (optional int)Minutes from ever)
Parameter Type 📝 Description
EventID string Event Id
Minutes from ever optional int Minutes from ever to register the event, if left empty the current time will be used.

Game.AddEvent

Adds an event to the game

Example

Game.AddEvent("test")
Adds an event with id 'test' at the current time


RemoveEvent

 function Game.RemoveEvent((string)EventID)
Parameter Type 📝 Description
EventID string Event Id

Game.RemoveEvent

Remove an event from the game

Example

Game.RemoveEvent("test")
Removes an event with id 'test' if one exists.

Comments