Built-in Functions

These functions are built into HUD.utility.rlv.1 and HUD.utility.plugin.lsl scripts.

You can copy them into your own scripts if you wish, though some functions require certain global variables to work.

Edit the HUD.utility.rlv.1 script if you want to add RLV functionality.

Otherwise, if you’re adding non-RLV features, edit the HUD.utility.plugin.lsl script instead.

Navigation

addRLVButton(string button)

– adds a button to the uHUD RLV Menu

init() {
	...
	addRLVButton("Relay"); //adds a button called "relay" on the RLV menu.
	...
}

default {
	listen(integer channel, string name, key id, string msg) {
		//the RLV menu buttons are on rlvMenuChannel
		if (channel == rlvMenuChannel) {
			if (msg == "Relay") //do something;
		}
	}
}

remRLVButton(string button)

– removes a button to the uHUD RLV Menu

	//if you're done with the button, you can remove it from the RLV menu.
	remRLVButton("Relay");

addPluginButton(string button)

– adds a button to the uHUD Plugin Menu

init() {
	...
	addPluginButton("Pause AO"); //adds a button called "Pause AO" on the Plugin menu.
	...
}

default {
	listen(integer channel, string name, key id, string msg) {
		//the Plugin menu buttons are on pluginMenuChannel
		if (channel == pluginMenuChannel) {
			if (msg == "Pause AO") llWhisper(1,"AO Off");
		}
	}
}

remPluginButton(string button)

– removes a button to the uHUD Plugin Menu

	//if you're done with the button, you can remove it from the Plugin menu.
	remPluginButton("Relay");

showMenu(string activeMenu, key avieKey, integer randChannel, string dlgMsg, string buttons)

shows menu to avieKey, in a consistent LULU uHUD menu format.

– will automatically handle multi-page scrolling for you. Just one showMenu() is required.

– activeMenu: the unique menu “header” that describes and represents this menu. e.g. “RLV RELAY”.

– avieKey: menu is sent to this key.

– randChannel: your unique random channel. You need to listen on this channel for the buttons.

– dlgMsg: message that is given in the menu.

– buttons: CSV of buttons, or special keyword “WORLD_OBJECT”, or blank “”.

– “WORLD_OBJECT” will automatically populate buttons with inworld objects. When button is pressed, controller script will return the object key via a link_message where num=-300, id=activeMenu, msg=objectKey + “|” + isOwner; where isOwner is a boolean integer to tell you whether the object was selected by sub’s owner. (See ‘forcesit’ example in HUD.utility.rlv.1.lsl)

listen(integer channel, string name, key id, string msg) {
	...
	if (msg == "LULU Gear") {
		//shows LULU-formatted menu to id, will handle scrolling automatically
		//if buttons require more than one page.
		showMenu(
			"MY MENU",
			id,
			-7234283,
			"What would you like " + avieFirstName + " to wear?",
			"collar,cuffs,gag"
		);
	}
	else if (msg == "collar") //do something;
	else if (msg == "cuffs") //do something;
	else if (msg == "gag") //do something;
	...
}

See also ownerPressedElseMsg()to allow only owners to use the buttons.

Feedback messages

whisper(string message)

whispers the text, automatically respecting the sub’s spacial “text” setting (click white LULU logo on HUD > “settings” or “preferences” > “text…”).

– this is the same setting as the uHUD global variable spacial

– if setting is 3, will use llSay().

– if setting is 2, will use llWhisper().

– if setting is 1, will use llRegionSayTo() to all owners in sim, plus sub.

– if setting is 0, will ignore.

//smarter way to 'llWhisper()', respecting sub and owner's text settings.
whisper(llKey2Name(llGetOwner()) + " is happy.");

See also spacial global variable.

sayTo(key id,string message)

sends a private message to an avie such that the object name is not shown. This helps in RP.

sayTo(llGetOwner(),"You try to unlock this, but it won't budge.");
// sub will see:
//.: You try to unlock this, but it won't budge. :.

integer ownerPressedElseMsg(string errMsg)

returns TRUE if global variable ownerPressed is true (i.e. last listen() event was triggered by sub’s owner).

returns FALSE if ownerPressed is false, AND sends a menu to the sub with the custom text errMsg.

– if noErr is blank (“”), then the default “Sorry, only your owner can operate this button” message is given.

– the menu has a “back” button that will return to the previous menu called by showMenu()

listen(integer channel, string name, key id, string msg) {
     ...
     if (ownerPressedElseMsg("Nice try! You cannot unlock what your owner has locked.")) {
          //unlock etc.;
     }
     //no else necessary, sub will be automatically given error message.
}

See also ownerPressed global variable.

See also showMenu() which is required for the “back” button to return to the correct menu.

Locking the uHUD

Sometimes, you may want to “lock” the uHUD (via RLV “@detach=n”) which prevents the sub from detaching the uHUD and from editing the scripts.

Do not issue your own “@detach=n” or “@detach=y” as this may mess with other plugins that require the uHUD to be locked. Instead, use the functions below and leave it to the controller script to sync the wishes of all the plugins.

lockUHUD(string pluginName, integer lockOn)

– tells the controller script that pluginName wants to lock or unlock the uHUD.

pluginName: Name of your plugin that will show up in the uHUD lock status as causing the uHUD to be locked.

lockOn: 1 to lock, 0 to unlock

– when locking, controller will always issue “@detach=n” (if RLV is active).

– when unlocking, controller will only issue “@detach=y” if no other plugin require the uHUD to be locked.

integer uHUDLocked; //used by 'lock uHUD' button, 1 = locked, 0 = unlocked.

	listen(integer channel, string name, key id, string msg) {
		...
		if (msg == "lock uHUD") {
			uHUDLocked = 1;
			lockUHUD("Lock uHUD",1);
			remRLVButton("lock uHUD");
			addRLVButton("unlock uHUD");
		}
		...
	}

Caution!

Sub can always reset the uHUD, and that might cause your script to lose track of its state.

To counter this, on reset, the controller will send out link_messages that informs plugins whether they have “@detach=n” active. If your plugin is on the list, you can re-assert your plugin state accordingly.

	link_message(integer sender_num, integer num, string msg, key id)     {
		//on script reset, OR if any plugin issues a lockUHUD() call,
		//the controller script will send out the CSV of plugins currently locking the uHUD.
		if (id == "uHUDLockCSV) {
			//if true, it means the plugin state was true before the script reset.
			if (isUHUDLockedBy("lock uHUD")) {
				//only fix this if this script is out of sync with the controller script.
				if (!uHUDLocked) {
					uHUDLocked = 1;
					remRLVButton("lock uHUD");
					addRLVButton("unlock uHUD");
				}
			}
		}
	}

See also get(“uHUDLockCSV”) to manually get the uHUDLockCSV.

See also isHUDLockedBy() below.

integer isUHUDLockedBy(string pluginName)

– returns TRUE if pluginName is currently causing the uHUD to be locked.

– returns FALSE otherwise, though other plugins might be causing uHUD to be locked with “@detach=n”

//on script reset, we can find out the last plugin state.
//e.g. RLV Relay can have three ON states (Ask, Play, Auto) and one OFF state.
//- in this case, pluginName is actually plugin name (e.g. "Relay") plus plugin state (e.g. "On/Ask").
//- this means that in the original lockUHUD() call, the pluginName plus state must be used.
//- remember to issue lockUHUD(previousState,0) together with lockUHUD(newState,1).

if (isUHUDLockedBy("Relay On/Ask")) sayTo(llGetOwner(),"Relay is On/Ask");
else if (isHUDLockedBy("Relay On/Play")) sayTo(llGetOwner(),"Relay is On/Play");
else if (isHUDLockedBy("Relay On/Auto")) sayTo(llGetOwner(),"Relay is On/Auto");
else sayTo(llGetOwner(),"Relay is OFF");

Miscellaneous

get(string globalVar)

– tells controller to send global variables

– use globalVar = “all” to send all global variables.

– otherwise, use valid global variables names (see Global Variable list).

	//on reset, perhaps your script requires certain global variables.
	state_entry() {
		get("ownerKeyCSV");
		get("cmdChannel");
		get("isMale");
	}

Back to uHUD API

Or, go to Global Stats and Settings

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

dreams are made of these