Class engine.Savefile

Savefile code T-Engine4 savefiles are direct serialization of in game objects

Basically the engine is told to save your Game instance and then it will recursively save all that it contains: level, map, entities, your own objects, ...

The savefile structure is a zip file that contains one file per object to be saved. Unzip one, it is quite obvious

A simple object (that does not do anything too fancy in its constructor) will save/load without anything to code, it's magic! For more complex objects, look at the methods save() and loaded() in objects that have them

Functions

engine.Savefile.getCurrent ()

The save file that is currently open

engine.Savefile.setCurrent (save)

Set this save file as the current one

engine.Savefile.setSaveMD5Type (type)

Do we md5 the specified type when saving?

Local Functions

engine.Savefile.resolveSelf (o, base, allow_object)

Ensure compatability between saves

Methods

engine.Savefile:init (savefile, coroutine)

Init a savefile

engine.Savefile:close ()

Finishes up a savefile Always call it once done

engine.Savefile:delete ()

Delete the savefile, if needed Also deletes from steam cloud if it's available

engine.Savefile:addToProcess (o)

add to process

engine.Savefile:addDelayLoad (o)

Add a delayed load for object

engine.Savefile:getFileName (o)

Get the filename of the object

engine.Savefile:saveObject (obj, zip)

Save the object to specified zip

engine.Savefile:nameSaveWorld (world)

Get a savename for a world

engine.Savefile:nameLoadWorld ()

Get a savename for a world

engine.Savefile:saveWorld (world, no_dialog)

Save the given world

engine.Savefile:saveQuickBirth (descriptor)

Save the given birth descriptors, used for quick start

engine.Savefile:loadQuickBirth ()

Load the given birth descriptors, used for quick start

engine.Savefile:saveScreenshot (screenshot)

Saves the screenshot of a game

engine.Savefile:nameSaveGame (game)

Get a savename for a game

engine.Savefile:nameLoadGame ()

Get a savename for a game

engine.Savefile:saveGame (game, no_dialog)

Save the given game

engine.Savefile:nameSaveZone (zone)

Get a savename for a zone

engine.Savefile:nameLoadZone (zone)

Get a savename for a zone

engine.Savefile:saveZone (zone, no_dialog)

Save a zone

engine.Savefile:nameSaveLevel (level)

Get a savename for a level

engine.Savefile:nameLoadLevel (zone, level)

Get a savename for a level

engine.Savefile:saveLevel (level, no_dialog)

Save a level

engine.Savefile:nameSaveEntity (e)

Get a savename for an entity

engine.Savefile:nameLoadEntity (name)

Get a savename for an entity

engine.Savefile:saveEntity (e, no_dialog)

Save an entity

engine.Savefile:loadReal (load)

Actually load an object

engine.Savefile:loadWorld ()

Loads a World

engine.Savefile:loadWorldSize ()

Gets the filesize of a World savefile

engine.Savefile:loadGame ()

Loads a Game delay_fct is all of the delayLoad functionality for the save file

engine.Savefile:loadGameSize ()

Gets the filesize of the Game savefile

engine.Savefile:loadZone (zone)

Loads a Zone executes all delayLoad automatically

engine.Savefile:loadLevel (zone, level)

Loads a Level all delayLoad executes automatically

engine.Savefile:loadEntity (name)

Loads an entity automatically executes delayLoad

engine.Savefile:checkValidity (type, object)

Checks validity of a kind

engine.Savefile:check ()

Checks for existence

engine.Savefile:md5Upload (type, f)

Upload type as md5

engine.Savefile:md5Check (type, f[, loadgame=`Game`])

Check if md5 is correct

engine.Savefile:badMD5Load ()

Called when our md5 is bad



Functions

engine.Savefile.getCurrent () STATIC
The save file that is currently open

Returns:

    current save
engine.Savefile.setCurrent (save) STATIC
Set this save file as the current one

Parameters:

Returns:

    current save
engine.Savefile.setSaveMD5Type (type) STATIC
Do we md5 the specified type when saving?

Parameters:

Local Functions

Methods
engine.Savefile.resolveSelf (o, base, allow_object)
Ensure compatability between saves

Parameters:

  • o object
  • base base object
  • allow_object allow the object to save (called recursively)

Methods

engine.Savefile:init (savefile, coroutine)
Init a savefile

Parameters:

  • savefile the name of the savefile, usually the player's name. It will be sanitized so dont bother doing it
  • coroutine if true the saving will yield sometimes to let other code run
engine.Savefile:close ()
Finishes up a savefile Always call it once done
engine.Savefile:delete ()
Delete the savefile, if needed Also deletes from steam cloud if it's available
engine.Savefile:addToProcess (o)
add to process

Parameters:

  • o
engine.Savefile:addDelayLoad (o)
Add a delayed load for object

Parameters:

  • o
engine.Savefile:getFileName (o)
Get the filename of the object

Parameters:

  • o

Returns:

    "main"

Or

    o.__CLASSNAME.."-"..tostring(o):sub(8)
engine.Savefile:saveObject (obj, zip)
Save the object to specified zip

Parameters:

  • obj currentsavemain
  • zip

Returns:

    int of how many processed
engine.Savefile:nameSaveWorld (world)
Get a savename for a world

Parameters:

Returns:

    "world.teaw"
engine.Savefile:nameLoadWorld ()
Get a savename for a world

Returns:

    "world.teaw"
engine.Savefile:saveWorld (world, no_dialog)
Save the given world

Parameters:

  • world World the world to save
  • no_dialog boolean show a popup when saving?
engine.Savefile:saveQuickBirth (descriptor)
Save the given birth descriptors, used for quick start

Parameters:

  • descriptor table {key, value}
engine.Savefile:loadQuickBirth ()
Load the given birth descriptors, used for quick start

Returns:

    nil

Or

    table
engine.Savefile:saveScreenshot (screenshot)
Saves the screenshot of a game

Parameters:

  • screenshot the screenshot to write to
engine.Savefile:nameSaveGame (game)
Get a savename for a game

Parameters:

Returns:

    "game.teag"
engine.Savefile:nameLoadGame ()
Get a savename for a game

Returns:

    "game.teag"
engine.Savefile:saveGame (game, no_dialog)
Save the given game

Parameters:

  • game Game
  • no_dialog boolean Show a popup when saving?
engine.Savefile:nameSaveZone (zone)
Get a savename for a zone

Parameters:

Returns:

    "zone-%s.teaz"
engine.Savefile:nameLoadZone (zone)
Get a savename for a zone

Parameters:

Returns:

    "zone-%s.teaz"
engine.Savefile:saveZone (zone, no_dialog)
Save a zone

Parameters:

  • zone Zone
  • no_dialog optional boolean Show a popup when saving?
engine.Savefile:nameSaveLevel (level)
Get a savename for a level

Parameters:

Returns:

    "level-%s-%d.teal"
engine.Savefile:nameLoadLevel (zone, level)
Get a savename for a level

Parameters:

Returns:

    "level-%s-%d.teal"
engine.Savefile:saveLevel (level, no_dialog)
Save a level

Parameters:

  • level Level
  • no_dialog optional boolean Show a popup when saving?
engine.Savefile:nameSaveEntity (e)
Get a savename for an entity

Parameters:

  • e

Returns:

    "entity-%s.teae"
engine.Savefile:nameLoadEntity (name)
Get a savename for an entity

Parameters:

  • name

Returns:

    "entity-%s.teae"
engine.Savefile:saveEntity (e, no_dialog)
Save an entity

Parameters:

  • e Entity
  • no_dialog optional boolean Show a popup when saving?
engine.Savefile:loadReal (load)
Actually load an object

Parameters:

  • load

Returns:

    nil

Or

    o
engine.Savefile:loadWorld ()
Loads a World

Returns:

  1. nil
  2. "no savefile"

Or

    World
engine.Savefile:loadWorldSize ()
Gets the filesize of a World savefile

Returns:

  1. nil
  2. "no savefile"

Or

    size
engine.Savefile:loadGame ()
Loads a Game delay_fct is all of the delayLoad functionality for the save file

Returns:

  1. nil
  2. "no savefile"

Or

  1. Game
  2. delay_fct
engine.Savefile:loadGameSize ()
Gets the filesize of the Game savefile

Returns:

  1. nil
  2. "no savefile"

Or

    size
engine.Savefile:loadZone (zone)
Loads a Zone executes all delayLoad automatically

Parameters:

Returns:

    false

Or

    Zone
engine.Savefile:loadLevel (zone, level)
Loads a Level all delayLoad executes automatically

Parameters:

Returns:

    false

Or

    Level
engine.Savefile:loadEntity (name)
Loads an entity automatically executes delayLoad

Parameters:

Returns:

    false

Or

    Entity
engine.Savefile:checkValidity (type, object)
Checks validity of a kind

Parameters:

  • type string "Entity" | "World" | "Level" | "Zone"
  • object the object to check

Returns:

    true if valid
engine.Savefile:check ()
Checks for existence

Returns:

    true if exists
engine.Savefile:md5Upload (type, f)
Upload type as md5

Parameters:

See also:

engine.Savefile:md5Check (type, f[, loadgame=`Game`])
Check if md5 is correct

Parameters:

  • type string savefile type
  • f string filename
  • loadgame game we're loading, defaults to static Game (default `Game`)

Returns:

    fct() return false end

Or

    fct() return true end

See also:

engine.Savefile:badMD5Load ()
Called when our md5 is bad
generated by LDoc 1.4.3