Deprecated: str_replace(): Passing null to parameter #1 ($search) of type array|string is deprecated in /var/www/vhosts/gamedevstudiogame.com/httpdocs/classes/client.php on line 124

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /var/www/vhosts/gamedevstudiogame.com/httpdocs/classes/client.php on line 124

Deprecated: htmlspecialchars_decode(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/vhosts/gamedevstudiogame.com/httpdocs/classes/client.php on line 57

Deprecated: htmlspecialchars_decode(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/vhosts/gamedevstudiogame.com/httpdocs/classes/client.php on line 58

Deprecated: htmlspecialchars_decode(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/vhosts/gamedevstudiogame.com/httpdocs/classes/client.php on line 59
Game dev studio

Classes

Concepts

loadComponent »

Libraries

Objects

remove

Description

Gets called when the game state is removed (ie. quitting to main menu or loading a savefile)

Example

myModClass = {}
myModClass.id = "myUniqueModID"
myModClass.priority = 1

function myModClass:remove()
    -- even if you don't need this, still declare it, since the game will still attempt to call this method

end

function myModClass:load(loadedData)
    -- since mod data is not guaranteed to be in a savefile upon loading (ie. start game without mod, save game, install mod, load game)


    -- you will need to check whether the data is present at all

    if loadedData then
        self.someVarOne = loadedData.someVarOne
        self.someVarTwo = loadedData.someVarTwo
    end
end

function myModClass:save()
    return {
        someVarOne = self.someVarOne,
        someVarTwo = self.someVarTwo
    }
end

game.addLoadComponent(myModClass, myModClass.id, myModClass.priority)