Skip to content
nhmkdev edited this page Jan 4, 2014 · 11 revisions

Definition

The save system is a collection of partitioned values.

  • Flags - non-negative numeric values
  • Tags - Strings

When a value is set in the save it is also partitioned based on the type of data.

Pseudo Code

Save.setFlag(partition, name, 4);
... behind the scenes simplification:
Save[flags][partition][name] = 4;

Container

var Save = ig.global.support.save;

Associated Functionality

Requirements Concept / Logic

The requirements object is used throughout the framework to provide a method of logic within the data instead of writing script in every instance. The requirements system is solely based on the Save flag system.

Basic requirement object format:

{
    l:'or', // the logical type for the list of items - a value of 'and' or 'or' (default: 'and')
    i:[] // array of arrays / requirement objects
}

Actual checks for logic are specified in an array as follows (array of strings):

[save partition, save item name, logical check]

Why so convoluted?! Good question. It's a bit ugly but the arrays are directly fed into a method and eval is only used to check the logical component specified in the third item of the array.

The sample below is one showing the logic of a requirement using an or. If the flag 'lap' in partition 't' is 2 or 3 the requirement passes.

Requirements.enableBlaster =
{
    l:'or',
    i:[ ['t','lap','==2'],['t','lap','==3'] ]
}

The sample below is one showing the logic of a requirement using an 'and' (defaulted) and an 'or' combined. Note that the array of items in 'i' can contain both arrays of requirements to check and other requirement objects.

Requirements.enableBlaster =
{
    i:
    [
    	['t','racing',==1],
	    {
		    l:'or',
		    i:[ ['t','lap','==2'],['t','lap','==3'] ]
	    }
    ]
}

// this is the equivalent of ((t.racing == 1) && (t.lap==2 || t.lap==3))

Action Concept / Logic

The action object is used through the framework to provide a method of adjusting values at a given point. The actions system is solely based on the Save flag system.

Basic action object format:

{
	sv:[], // Values to set (default: null)
	sd:[], // Values to decrement (default: null)
	si:[], // Values to increment (deftaul: null)
	k:true // Whether to call .kill() on the entity (default: false) (NOTE: applies to ??? only)
}

Actual value sets are specified in an array as follows:

[save partition, save item name ,amount] (amount is a number in all cases -- only required for 'sv')

Sample that increments the i.gt value by 1

a:
{
	si:[ ['i','gt',1] ],
	k:true
}

temp partition

The 't' partition is automatically wiped on level load and are never persisted to the actual save game. (TODO: verify the previous statement :))

Clone this wiki locally