SaveState
Script function

world.SaveState

DOC_scripting Read about scripting

Type

Method

Summary

Saves the state of the current plugin

Prototype

long SaveState();

DOC_data_types View list of data type meanings


Description

This causes the current plugin to save its state (ie. its variables) to its "state" file. You might call this in a timer every couple of minutes to ensure that variables are saved in the event of a program or computer crash.

To save its state a plugin must have

save_state="y"

in its plugin configuration.

Plugins automatically save their state when they are closed (ie. when they are uninstalled, or when the world closes). However if the world does not close for days then you may want to arrange for the plugin to save its state more often, particularly if the variables that the plugin is using are valuable.

The plugins save their state to a directory called "state" which is a subdirectory of the nominated "world plugins directory". If no such directory exists, then the plugin cannot save its state.

There is a state file for each world/plugin combination.

The file name will look like this:

a282eaabbecd18a56aa07f84-c8efc9f9e1edd118c6f2dbf5-state.xml

This is:

(world ID)-(plugin ID)-state.xml

Each world should have a unique ID, and each plugin should have a unique ID, thus each world's plugin's state should have a unique file name.



VBscript example

world.SaveState



Jscript example

world.SaveState ();



PerlScript example

$world->SaveState ();



Python example

world.SaveState 



Lua example

SaveState ()



Return value

eNotAPlugin: Script is not currently executing inside a plugin.
ePluginDoesNotSaveState: This plugin is not configured to save its state.
ePluginCouldNotSaveState: The plugin could not save its state (eg. no "state" directory, disk full, not permitted)
eOK: Plugin saved its state OK.


DOC_errors View list of return code meanings


See Also ...

Topics

DOC_aliases Aliases
DOC_Arrays Arrays
DOC_plugins Plugins
DOC_scripting Scripting
DOC_timers Timers
DOC_triggers Triggers
DOC_variables Variables

Functions

FNC_BroadcastPlugin BroadcastPlugin (Broadcasts a message to all installed plugins)
FNC_CallPlugin CallPlugin (Calls a routine in a plugin)
FNC_EnablePlugin EnablePlugin (Enables or disables the specified plugin)
FNC_GetPluginID GetPluginID (Returns the 24-character ID of the current plugin)
FNC_GetPluginInfo GetPluginInfo (Gets details about a specified plugin)
FNC_GetPluginList GetPluginList (Gets a list of installed plugins.)
FNC_GetPluginName GetPluginName (Returns the name of the current plugin)
FNC_GetPluginTimerInfo GetPluginTimerInfo (Gets details about a named timer for a specified plugin)
FNC_GetPluginTimerList GetPluginTimerList (Gets the list of timers in a specified plugin)
FNC_GetPluginVariable GetPluginVariable (Gets the contents of a variable belonging to a plugin)
FNC_GetPluginVariableList GetPluginVariableList (Gets the list of variables in a specified plugin)
FNC_IsPluginInstalled IsPluginInstalled (Checks to see if a particular plugin is installed)
FNC_LoadPlugin LoadPlugin (Loads a plugin from disk)
FNC_PluginSupports PluginSupports (Checks if a plugin supports a particular routine)
FNC_ReloadPlugin ReloadPlugin (Reloads an installed plugin)

(Help topic: function=SaveState)

DOC_contents Documentation contents page