Lib Config

From Elite Wiki
Jump to: navigation, search
IconLib.png

Overview

Lib_Config (part of Library) is a Interface to give AddOns the possibility to let users change settings in the game. It's really easy to implement the data and usually only needs a few lines of code. AddOns can also register multiple entries if they need some more options.


Methods

_registerSet

_registerSet: function( obj )

Register a data set on .startUpComplete or later.

Parameters:

obj
Object. See Full Dataset for its members.

Returns:

n
Number. Errorcode. If OK 0 (zero).


_unregisterSet

_unregisterSet: function( obj )

Unregister a data set.

Parameters:

obj
Object. See Full Dataset for its members.

Returns:

n
Number. Errorcode. If OK 0 (zero).


Examples

A very simple one with 1 boolean property to stare at:

 this.$log = false;
 this.$myOXPC = {Name:this.name, Display:"Example A", Alive:"$myOXPC",
    Bool:{
      B0:{Name:"$log", Def:false, Desc:"Blurp."},
      Info:"Hmmm."
    }
 };
 worldScripts.Lib_Config._registerSet(this.$myOXPC);

Pathes can be used as well:

 this.$path = {
   dog: {dog:false},
   notify: function(boo){
     log("","Path Notify for "+boo);
   }
 };
 this.$myOXPC = {Name:this.name, Display:"Path", Alive:"$myOXPC", Notify:"$path.notify",
   Bool:{
     B0:{Name:"$path.dog.dog", Def:false, Desc:"Blurp.", Notify:"$path.notify"},
     Info:"OK", Notify:"$path.notify"
   }
 };
 worldScripts.Lib_Config._registerSet(this.$myOXPC);


Full Dataset

The members:

Name
Required. String. worldScript name, usually simply this.name.
Display
Required. String. Identifier for this specific settings Object, e.g. "Planets". Name and Display are used to sort and group settings Objects.
Alive
Required. String. Path to settings Object, e.g. "$mySettings".
Notify
Optional. String. Path to global notification function when user leaves the OXP screen.
Reset
Optional. Boolean. If set allows "Reset to defaults" option. See Reset option.

and at least one of

Bool
Boolean handling.
B0
Up to 9 unique Objects.
Name
Required. String. Path to boolean property, e.g. "$switchOn".
Def
Required. Boolean. Default value.
Desc
Required. String. Short description, e.g. "Add planets".
Hide
Optional. Boolean. Hide from display.
Notify
Optional. String. Path to notification function when user changes this property.
},
Info
Optional. String. Description for the boolean settings. If prefixed with '^' points to a missiontext key.
Notify
Optional. String. Path to group notification function when user leaves the boolean screen.
},
SInt
Number handling. Integer or Float. Used values can be in range -16777215...16777215 (or -0xffffff...0xffffff).
S0
Up to 9 unique Objects.
Name
Required. String. Path to integer or float property, e.g. "$amountMoons".
Def
Required. Number. Default value.
Min
Required. Number. Minimum value, e.g. -43.
Max
Required. Number. Maximum value, e.g. 0xfffffe.
Desc
Required. String. Short description, e.g. "Max planets".
Float
Optional. Boolean. If true floating point input allowed.
Hide
Optional. Boolean. Hide from display.
Notify
Optional. String. Path to notification function when user changes this property.
},
Info
Optional. String. Description for the number settings. If prefixed with '^' points to a missiontext key.
Notify
Optional. String. Path to group notification function when user leaves the number screen.
},
EInt
Bitmask handling. Positive Integer. Used values can be in range 0...16777215 (or 0x0...0xffffff).
E0
1 object.
Name
Required. String. Path to bitmask property, e.g. "$myBitmask".
Def
Required. Number. Default value.
Min
Required. Number. Minimum value.
Max
Required. Number. Maximum value.
Desc
Required. Array. Contains Strings, describing the single elements.
Hide
Optional. Boolean. Hide from display.
Notify
Optional. String. Path to notification function when user changes this property.
OneOf
Optional. Boolean. Selects only one bit at a time.
OneOfZero
Optional. Boolean. Selects only one bit or none at a time.
},
Info
Optional. String. Description for the bitmask settings. If prefixed with '^' points to a missiontext key.
Notify
Optional. String. Path to group notification function when user leaves the bitmask screen.
}

Reset option

Lib_Configs "Reset to defaults" option handles the notifications as follows:

  • If a global .Notify is declared it ignores group or property .Notify
  • If no global .Notify and a group .Notify is declared it ignores property .Notify