Blockland Glass Developer's GuideThis documentation is way overdue, but late is better than never.
PreferencesGlass automatically brings in any old RTB preferences, already supporting nearly all RTB add-ons.
You can create a new preference category for your add-on with the registerPreferenceAddon function:
registerPreferenceAddon(%addon, %name, %icon); registerPreferenceAddon("System_BlocklandGlass", "Glass Prefs", "gear");The preference itself is registered objectively, similar to Datablocks. An example is below:
//Object-based preference initialization
registerPreferenceAddon("System_BlocklandGlass", "Glass Server 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) {
//myRealUpdateCallback 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;
}
The following preference types and parameters have been defined by Support_Preferences:
- bool
- num <min> <max> <precision>
- playercount <min> <max>
- string <len> <strip ml>
- slider <min> <max> <snapTo> <stepValue>
- dropdown <name1> <value1> <name2> <value2> ...
- wordlist <delimiter> <maxWords>
- color
- datablock <type> <canBeNone>
- datablocklist <max words>
- button
- colorset
- rgb <has alpha>
However, only types used by RTB have been implemented along with RGB. The rest can be implemented at request (probably all of them in a single update).
Required ClientsGlass allows servers to set required or optional client sided add-ons to use while playing. Once it's setup Glass will automatically handle the downloads and prompting of downloads for the client. This is the function to register a required client:
registerRequiredClient(%name, %glassId, %optional);%name - This appears to the client when connecting, you can name your add-on whatever you like. It does not have to be the same as it is on Glass.
%glassId - The Glass ID of your add-on, this can be found in the url of the add-on. (Example: add-on.php/id=398 your ID would be 398).
%optional - Set this to 1 if you want the client to be an optional download.
Example:
registerRequiredClient("Jailbreak Client", 135, 0);Loading ScreensGlass allows gamemode creators to set custom loading backgrounds for users loading their gamemode. Setup is quite simple:
registerLoadingScreen(%url, %fileType[, %crc]);Calling this method inside your gamemode makes clients (who have loading backgrounds enabled) download the specified image URL. Any jpeg, png, or jpg image is supported. Note that Glass has to be running on the server.
%crc is an optional field allowing the client to cache your server's preview image. If a client already has the loading image with the given CRC downloaded, the image will load automatically without needing to be downloaded.
Example:
registerLoadingScreen("http://mysite.com/image.png", "png");The background must be below 2MB in file size, or else it won't load!
Player ListA lot of servers have more than just the normal admin and super admin ranks so Glass allows server hosts to set their client's rank on the server list. This can be done by calling a client command to update the letter.
clientCmdGlass_setPlayerlistS tatus(%blid, %char, %color);%blid - The BL_ID of the client you would like to change.
%char - The desired character. This has a limit of one letter.
%color - The color you would like the line to be.
Color code:
1 = Black
2 = Grey
3 = Light Grey
4 = Pinkish Red
5 = Blue
6 = Red
7 = Green
8 = Orange
9 = Teal
Example:
commandToAll('Glass_setPlayerlistStatus', 2143, "J", 7);