Key Value Spec API

From HEWIKI
Jump to: navigation, search

Contents

Key Value Specs provide a mechanism to specify sets of arbitrary key-value pairs of data. A key-value pair means a value associate with a specific text string. Any number of key-value pairs can be added to a spec, and the spec is identified by a ID. Then, at any time, you can pass the reference to that spec by ID to various systems that use the Key Value Spec mechanism. Since you are only passing the ID to the spec once it is created, this is a very high-speed mechanism.

This can also be used by HSL or a HeroScript Extension Plugin. The primary usage is for the HeroPath system and the Decal System.

Usage

// --------------------------------------------------------------------------------------------
//
// KeyValueSpec and KeyValueData provides an API to create data specifications and easily set
// and retreive data values as well as pass them to various routines.
//
// Example HSL usage:
// ----------------------------------------------------------
//  CreateKeyValueSpec("GroundedPath","")           // Creates a named KeyValueSpec called 'GroundedPath'
//  AddKeyValueSpec("GroundedPath","step_value      = float,0.05,0.01,0.4       # Distance between smoothed data points")
//  AddKeyValueSpec("GroundedPath","tightness       = float,1.0,0.1,100         # Distance between control points")
//  AddKeyValueSpec("GroundedPath","check_above     = float,4.0,0.01,100        # Height above to start grounding")
//  AddKeyValueSpec("GroundedPath","walk_slope      = float,45,1,85             # Walk slope for the character")
//  AddKeyValueSpec("GroundedPath","char_width      = float,0.03,0.01,1         # The character width")
//  AddKeyValueSpec("GroundedPath","char_height     = float,0.165,0.01,1        # The character height")
//  AddKeyValueSpec("GroundedPath","collision_group = string,CGF_PATH_COLLISION # Specifies the collision group flags to use.")
//  data as ID;
//  data = createKeyValueData("GroundedPath","step_value=0.05,tightness=1,check_above=4,walk_slope=45,char_width=0.03,char_height=0.165,collision_group=CGF_PATH_COLLISION")
//  SetKeyValueData(data,"step_value=0.06")
//  SetKeyValueDataFloat(data,"step_value",0.06)
//  stepValue as Float
//  GetKeyValueDataFloat(data,"step_value",stepValue)
//  ReleaseKeyValueData(data)
//  ReleaseKeyValueSpec("GroundedPath")
//
 
// create/release and add to a KeyValueSpecification.
external function CreateKeyValueSpec(specName as String,specification as String) as Boolean
external function ReleaseKeyValueSpec(specName as String) as Boolean
external function AddKeyValueSpec(specName as String,specification as String) as Boolean
external function GetKeyValueSpecList(outList references List of String) as Integer
external function EnumerateKeyValueSpec(specName as String,outList references List of Class _KeyValueData) as Boolean
external function DoesKeyValueSpecExist(specName as String) as Boolean
external function GetKeyValueSpecVersion(specName as String,version references Integer) as Boolean
external function GetKeyValueSpecDefaultData(specName as String) as ID
external function GetKeyValueSpecification(specName as String,specification references String) as Boolean
 
// Create an instance of the data items associated with this specification.
external function CreateKeyValueData(specName as String,data as String) as ID
external function SetKeyValueData(data as ID,values as String) as Boolean
external function GetKeyValueData(_id as ID,data references String) as Boolean
external function ReleaseKeyValueData(data as ID) as Boolean
external function EnumerateKeyValueData(_id as ID,outList references List of Class _KeyValueData) as Boolean
external function DoesKeyValueDataExist(_id as ID) as Boolean
external function GetKeyValueDataList(specName as String,outList references List of ID) as Integer
external function GetKeyValueDataVersion(_id as ID,version references Integer) as Boolean
 
 
// set/get data values based on a particular key
external function GetKeyValueDataBoolean(data as ID,key as String,state references Boolean) as Boolean
external function GetKeyValueDataVector3(data as ID,key as String,state references Vector3) as Boolean
external function GetKeyValueDataFloat(data as ID,key as String,state references Float) as Boolean
external function GetKeyValueDataInteger(data as ID,key as String,state references Integer) as Boolean
external function GetKeyValueDataString(data as ID,key as String,state references String) as Boolean
 
external function SetKeyValueDataBoolean(data as ID,key as String, state as Boolean) as Boolean
external function SetKeyValueDataVector3(data as ID,key as String, state as Vector3) as Boolean
external function SetKeyValueDataFloat(data as ID,key as String, state as Float) as Boolean
external function SetKeyValueDataInteger(data as ID,key as String, state as Integer) as Boolean
external function SetKeyValueDataString(data as ID,key as String, state as String) as Boolean

See also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox