Repository navigation
Expand file tree
/
Copy pathexample.cs
More file actions
51 lines (38 loc) · 1.61 KB
/
Copy pathexample.cs
File metadata and controls
51 lines (38 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//Object-based preference initialization
// This is both an example and unit test
// Goal for Prefs v2.0
//registerPreferenceAddon(%addon, %title, %icon);My
registerPreferenceAddon("System_BlocklandGlass", "Prefs", "gear");
new ScriptObject(Preference) {
className = "MyCoolPref"; //namespace
addon = "System_BlocklandGlass"; //add-on filename
category = "General";
title = "Can use";
type = "dropdown";
params = "Host 3 Super_Admin 2 Admin 1"; //list based parameters
variable = "$Pref::BLPrefs::AllowedRank"; //global variable (optional)
defaultValue = "Super_Admin 2"; //two words due to dropdown
updateCallback = "myRealUpdateCallback"; //to call after ::onUpdate (optional)
loadCallback = "myRealUpdateCallback"; //to call after ::onLoad (optional)
hostOnly = true; //default false (optional)
secret = false; //whether to tell clients the value was updated (optional)
loadNow = false; // load value on creation instead of with pool (optional)
noSave = false; // do not save (optional)
requireRestart = false; // denotes a restart is required (optional)
};
function MyCoolPref::onUpdate(%this, %val) {
//realUpdateCallback should have already been called by now,
// handled by the Preference generic
echo("MyCoolPref::onUpdate");
if($Test::Pref $= %val) {
echo("Passed update callback test");
} else {
echo("Failed update callback test");
}
}
function MyCoolPref::onLoad(%this, %val) {
echo("Loaded \"" @ %this.title @ "\"");
}
function myRealUpdateCallback(%this, %val) {
$Test::Pref = %val;
}