Settings

Registering a new setting

You can register settings by putting them in the object when registering a module. In the following example we will create a new Module and give it a BooleanSetting and a ColorSetting.

breeze.registerModule("TestModule", "A module with settings!", {
    'aSetting': new BooleanSetting("Value", "A very important choice to make", false),
    'theColor': new ColorSetting("Color", "Everyone likes a cool color", new Color(29, 201, 150), false),
    
    'enable': function() {
        //we can change the behaviour of the module based on the values of the settings
        if (this.aSetting.getValue()) {
            breeze.log("Great choice!", this.theColor.getValue())
        } else {
            breeze.log(this.aSetting.getName() + " was not set to true")
        }
    }
}) 

Getting a existing setting

You can get a setting by using the getSetting(String name); method on a Module. If the module has a setting with the given name it will return a Setting object.

//Example of getting a setting and changing its value.

var aimAssist = breeze.getModule("AimAssist")
var range = aimAssist.getSetting("Range")
range.setValue(3.5)

//this code can all be compressed in to one line if wanted
breeze.getModule("AimAssist").getSetting("Range").setValue(3.5)

Last updated