CleanSave

by Ter13
Smaller, easier, safer savefiles. [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Ter13.CleanSave##version=2

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Ter13.CleanSave##version=2

399 downloads
Version 1.0a
Date added: Mar 4 2013
Last updated: Jul 3 2015
10 fans
CleanSave is a simple, forward-oriented saving system. The design is intended to interleave with the default BYOND saving system, allowing it to do what it does best, and stopping it from what it doesn't do very well.

For a tutorial on how to implement this system into your game, look here.

For a more basic tutorial on how saving works, look here

Notably, this system allows you to specify variables that are not marked tmp, const, or global that will never be saved per-object.

The system is easy to use, and incredibly intuitive.

To specify files that shouldn't be saved, the system adds a single function to datums:


NeverSave(var/list/L)


Args:
  • L a list passed from child to parent to specify what variables won't save.

returns:

  • A list of values that are not to be saved


Description:

NeverSave() is called internally by the saving system. When you define a type that has variables that aren't temp, const, or global that you want to save anyway, you call the parent proc, then add your items to the list, or remove items from the list, then return it.

Example

mob
player
var
list/foo = list()
NeverSave(var/list/L)
L = ..(L)
L.Add("foo")
L.Remove("icon")
return L


The above example defines a list foo, and adds it to the NeverSave list, which is called internally when objects are saved. Essentially, foo is effectively a temporary variable, which would be better achieved by setting foo to tmp anyway.

What this system was made to do, however, is make it so that several non-temporary internal variables are not saved to make setting up player saving behaviors a snap.

By default, this disables saving for:

atom.icon
atom.icon_state
atom.overlays
atom.underlays

atom/movable.screen_loc

mob.key

The removal of default saving of this system is to achieve one-line object saving, a more compact savefile on the hard drive, and in general, a more flexible saving and loading system without the pain of specifying each and every variable that needs to be saved.

Just tell the game what NOT to save, and it'll take care of everything else.

(This is not a substitution for marking variables as temporary!)

Comments

Zagros5000: (Mar 15 2015, 11:32 am)
am dum