GameClass
A script class that defines the game mode. Only one instance of this class is made.
This is the first script that will be run.
The game script is responsible for creating and managing Worlds.
The class can receive events sent with sm.event.sendToGame.
The fields below are accessed using self.fieldName
in the GameClass script:
Type | Name | Description |
---|---|---|
Network | network | A Network object that can be used to send data between client and server. |
Storage | storage | A server-side Storage object that can be used to save and load data to/from the world database. |
any | data | Game start data. |
defaultInventorySize
enableAggro
enableAmmoConsumption
enableFuelConsumption
enableLimitedInventory
enableRestrictions
enableUpgrade
Server-only
onPlayerJoined
function GameClass.server_onPlayerJoined( self, player, newPlayer )
end
Called when a Player joins the game.
self
[ table ]: The class instance.player
[ Player ]: The joining player.newPlayer
[ bool ]: True if the player has not been in this game before.
onPlayerLeft
function GameClass.server_onPlayerLeft( self, player )
end
Called when a Player leaves the game.
self
[ table ]: The class instance.player
[ Player ]: The leaving player.
onReset
function GameClass.server_onReset( self )
end
Called when the user wants to reset the challenge level.
Only works in Challenge Mode!
self
[ table ]: The class instance.
onRestart
function GameClass.server_onRestart( self )
end
Called when the user wants to restart the challenge level.
Only works in Challenge Mode!
self
[ table ]: The class instance.
onSaveLevel
function GameClass.server_onSaveLevel( self )
end
Called when the user wants to save the challenge level.
Only works in the Challenge Builder!
self
[ table ]: The class instance.
onTestLevel
function GameClass.server_onTestLevel( self )
end
Called when the user wants to save and test the challenge level.
Only works in the Challenge Builder!
self
[ table ]: The class instance.
onStopTest
function GameClass.server_onStopTest( self )
end
Called when the user wants to stop testing the challenge level.
Only works in the Challenge Builder!
self
[ table ]: The class instance.
Client-only
onLoadingScreenLifted
function GameClass.client_onLoadingScreenLifted( self )
end
Called when the loading screen is lifted when entering a game.
Arguments:self
[ table ]: The class instance.
onLanguageChange
function GameClass.client_onLanguageChange( self, language )
end
Called when the user changes the language in the in-game menu.
Valid languages are:
Brazilian
, Chinese
, English
, French
German
, Italian
, Japanese
, Korean
Polish
, Russian
, Spanish
self
[ table ]: The class instance.language
[ string ]: The new language.