sm.game
Used to check the state of the game.
Functions:
sm.game.banPlayer(player)
Server only
Ban a player from the server.
Parameters:
| Type | Name | Description |
|---|---|---|
| Player | player | The player to be banned. |
sm.game.bindChatCommand(command, params, callback, help)
Binds a chat command to a callback function. The callback function receives an array of parameters. The first parameter is the command itself.
Example:
sm.game.bindChatCommand( "/enable_client_toilet",
{ { "bool", "enabled", false } },
"onChatCommand",
"Enables or disables client toilet." ) function MyGameScript.onChatCommand( self, params ) if params[1] == "/enable_client_toilet" then self.settings.enable_client_toilet = params[2] end end
Parameters:
| Type | Name | Description |
|---|---|---|
| string | command | The command. |
| table | params | An array of parameters the callback function expects in the form of { { type, name (, optional, autocomplete ) }, ... }. The first is the type name of the parameter as a string. Valid types are "bool", "int", "number" and "string". The second is the name in the help text. Defaults to automatic naming ("p1", "p2", "p3", ...). The third is a bool value where true means that this parameter is optional (Optional, defaults to false). The fourth is a list of values that can be auto-completed to by pressing tab (Optional). |
| string | callback | The name of the Lua function to bind. |
| string | help | Help text. |
sm.game.exitToMenu()
Only for testing!
sm.game.exitToMenuWithEndCredits()
Exits to the main menu and requests the end-game credits sequence to play once there.
sm.game.getCurrentTick()
Return the current game tick.
Returns:
| Type | Description |
|---|---|
| integer | The tick. |
sm.game.getDifficulty()
Return the index of the current difficulty setting.
Returns:
| Type | Description |
|---|---|
| integer | index The difficulty index. |
sm.game.getEnableAggro()
Returns true if aggro is enabled and false if aggro is disabled.
Returns:
| Type | Description |
|---|---|
| boolean | The enable state. |
sm.game.getEnableAmmoConsumption()
Returns true if ammo consumption is enabled and false if ammo consumption is disabled.
Returns:
| Type | Description |
|---|---|
| boolean | The enable state. |
sm.game.getEnableFuelConsumption()
Returns true if fuel consumption is enabled and false if fuel consumption is disabled.
Returns:
| Type | Description |
|---|---|
| boolean | The enable state. |
sm.game.getEnableRestrictions()
Returns true if restrictions are enabled and false if restrictions are disabled.
Returns:
| Type | Description |
|---|---|
| boolean | The enable state. |
sm.game.getEnableUpgrade()
Returns true if upgrading is enabled and false if upgrading is disabled.
Returns:
| Type | Description |
|---|---|
| boolean | The enable state. |
sm.game.getLimitedInventory()
Return limited inventory state. If true the items are limited, if false the items are unlimited.
Returns:
| Type | Description |
|---|---|
| boolean | Is limited. |
sm.game.getRecipesEnabled()
Returns true if recipes is enabled and false if recipes are is disabled.
Returns:
| Type | Description |
|---|---|
| boolean | The enable state. |
sm.game.getServerTick()
Return estimated game tick on the server.
Returns:
| Type | Description |
|---|---|
| integer | The tick. |
sm.game.getSettingBoolean(name)
Get the boolean value of a named setting.
Parameters:
| Type | Name | Description |
|---|---|---|
| string | name | The name of the setting |
Returns:
| Type | Description |
|---|---|
| boolean | value The value of the setting. |
sm.game.getSettingString(name)
Get the string value of a named setting.
Parameters:
| Type | Name | Description |
|---|---|---|
| string | name | The name of the setting |
Returns:
| Type | Description |
|---|---|
| string | value The value of the setting. |
sm.game.getSettingValue(name)
Get the number value of a named setting.
Parameters:
| Type | Name | Description |
|---|---|---|
| string | name | The name of the setting |
Returns:
| Type | Description |
|---|---|
| number | value The value of the setting. |
sm.game.getTimeOfDay()
Return the fraction value of how far the current day has progressed.
Returns:
| Type | Description |
|---|---|
| number | The fraction of the day cycle. |
sm.game.kickPlayer(player)
Server only
Kick a player from the server.
Parameters:
| Type | Name | Description |
|---|---|---|
| Player | player | The player to be kicked. |
sm.game.loadWatchedTutorials()
Client only
Loads the users watched tutorials and returns it as a table.
Returns:
| Type | Description |
|---|---|
| table | Users watched tutorials table. |
sm.game.pauseSaving(waitName, ticks)
Server only
Pauses saving for the specified number of ticks. Server only.
If already paused, extends to the longer of current remaining and the requested ticks.
Parameters:
| Type | Name | Description |
|---|---|---|
| string | waitName | The name identifying this pause request. |
| integer | ticks | The number of ticks to pause saving for. |
sm.game.resumeSaving(waitName)
Server only
Resumes saving by removing a named pause request. Server only.
Parameters:
| Type | Name | Description |
|---|---|---|
| string | waitName | The name identifying the pause request to remove. |
sm.game.saveWatchedTutorials(watchedTutorials)
Client only
Saves the user's watched tutorials.
Parameters:
| Type | Name | Description |
|---|---|---|
| table | watchedTutorials | The table of watched tutorials. |
sm.game.setEnableAggro(enableAggro)
Server only
Enables and disables aggro. If true, player's will be detected as targets.
Parameters:
| Type | Name | Description |
|---|---|---|
| boolean | enableAggro | The enable state. |
sm.game.setEnableAmmoConsumption(enableAmmoConsumption)
Server only
Enables and disables ammo consumption. If true, ammo will be required to shoot spudguns.
Parameters:
| Type | Name | Description |
|---|---|---|
| boolean | enableAmmoConsumption | The enable state. |
sm.game.setEnableFuelConsumption(enableFuelConsumption)
Server only
Enables and disables fuel consumption. If true, fuel will be consumed from engines.
Parameters:
| Type | Name | Description |
|---|---|---|
| boolean | enableFuelConsumption | The enable state. |
sm.game.setEnableRecipes(enableRecipes)
Server only
Enables and disables recipes. If true, player's will need to unlock recipes before they become available for crafting.
Parameters:
| Type | Name | Description |
|---|---|---|
| boolean | enableRecipes | The enable state. |
sm.game.setEnableRestrictions(enableRestrictions)
Server only
Enables and disables the use of restrictions. If true restrictions will be applied, if false the restrictions will default to unrestricted.
Parameters:
| Type | Name | Description |
|---|---|---|
| boolean | enableRestrictions | Restrictions enable state. |
sm.game.setEnableUpgrade(enableUpgrade)
Server only
Enables and disables upgrade. If true, the Interactable can be upgraded with component kits.
Parameters:
| Type | Name | Description |
|---|---|---|
| boolean | enableUpgrade | The enable state. |
sm.game.setLimitedInventory(isLimited)
Server only
Sets limited inventory. If true the items are limited, if false the items are unlimited.
Parameters:
| Type | Name | Description |
|---|---|---|
| boolean | isLimited | Is limited. |
sm.game.setTimeOfDay(time)
Client only
Sets the fraction value of how far the current day has progressed.
Parameters:
| Type | Name | Description |
|---|---|---|
| number | time | The fraction of the day cycle. |