sm.game

Used to check the state of the game.

Functions:

  • bindChatCommand
  • getCurrentTick
  • getDifficulty
  • getEnableAggro
  • getEnableAmmoConsumption
  • getEnableFuelConsumption
  • getEnableRestrictions
  • getEnableUpgrade
  • getLimitedInventory
  • getServerTick
  • getTimeOfDay
  • setEnableAggro
  • setEnableAmmoConsumption
  • setEnableFuelConsumption
  • setEnableRestrictions
  • setEnableUpgrade
  • setLimitedInventory
  • setTimeOfDay

  • 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:

    TypeNameDescription
    stringcommandThe command.
    tableparamsAn array of parameters the callback function expects in the form of { { type, name, optional }, ... }. 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. Defaults to false.
    stringcallbackThe name of the Lua function to bind.
    stringhelpHelp text.

    sm.game.getCurrentTick()

    Return the current game tick.

    Returns:

    TypeDescription
    integerThe tick.

    sm.game.getDifficulty()

    Return the index of the current difficulty setting.

    Returns:

    TypeDescription
    integerindex The difficulty index.

    sm.game.getEnableAggro()

    Returns true if aggro is enabled and false if aggro is disabled.

    Returns:

    TypeDescription
    booleanThe enable state.

    sm.game.getEnableAmmoConsumption()

    Returns true if ammo consumption is enabled and false if ammo consumption is disabled.

    Returns:

    TypeDescription
    booleanThe enable state.

    sm.game.getEnableFuelConsumption()

    Returns true if fuel consumption is enabled and false if fuel consumption is disabled.

    Returns:

    TypeDescription
    booleanThe enable state.

    sm.game.getEnableRestrictions()

    Returns true if restrictions are enabled and false if restrictions are disabled.

    Returns:

    TypeDescription
    booleanThe enable state.

    sm.game.getEnableUpgrade()

    Returns true if upgrading is enabled and false if upgrading is disabled.

    Returns:

    TypeDescription
    booleanThe enable state.

    sm.game.getLimitedInventory()

    Return limited inventory state. If true the items are limited, if false the items are unlimited.

    Returns:

    TypeDescription
    booleanIs limited.

    sm.game.getServerTick()

    Return estimated game tick on the server.

    Returns:

    TypeDescription
    integerThe tick.

    sm.game.getTimeOfDay()

    Return the fraction value of how far the current day has progressed.

    Returns:

    TypeDescription
    numberThe fraction of the day cycle.

    sm.game.setEnableAggro(enableAggro)

    Server only

    Enables and disables aggro. If true, player's will be detected as targets.

    Parameters:

    TypeNameDescription
    booleanenableAggroThe enable state.

    sm.game.setEnableAmmoConsumption(enableAmmoConsumption)

    Server only

    Enables and disables ammo consumption. If true, ammo will be required to shoot spudguns.

    Parameters:

    TypeNameDescription
    booleanenableAmmoConsumptionThe enable state.

    sm.game.setEnableFuelConsumption(enableFuelConsumption)

    Server only

    Enables and disables fuel consumption. If true, fuel will be consumed from engines.

    Parameters:

    TypeNameDescription
    booleanenableFuelConsumptionThe 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:

    TypeNameDescription
    booleanenableRestrictionsRestrictions enable state.

    sm.game.setEnableUpgrade(enableUpgrade)

    Server only

    Enables and disables upgrade. If true, the Interactable can be upgraded with component kits.

    Parameters:

    TypeNameDescription
    booleanenableUpgradeThe enable state.

    sm.game.setLimitedInventory(isLimited)

    Server only

    Sets limited inventory. If true the items are limited, if false the items are unlimited.

    Parameters:

    TypeNameDescription
    booleanisLimitedIs limited.

    sm.game.setTimeOfDay(time)

    Client only

    Sets the fraction value of how far the current day has progressed.

    Parameters:

    TypeNameDescription
    numbertimeThe fraction of the day cycle.