Using the main navigation page of the HUD.
Setting up your sailboat.
Instructions on how to control your boat.
Hints on how to sail a boat.
The script in the HUD has a library of different kinds of buttons that it knows how to handle. You can add a new button, use one of the built in button types, and the HUD, the button and the COM script work together to send a message to your script in your boat. For example, you could add color change buttons to the the HUD without needing to add any new code to the HUD. You just need to add code to your boat to listen for the messages and change the color.
The way you do this is by linking new buttons to the HUD and putting documentation, type codes, and message strings into the name and description of your new button. The type then determines how the HUD script uses the message(s) that are stored in the button prim description. Most buttons on the HUD can be set up by making a copy of another button then changing the name and description. The name of the button prim has two parts, a unique name and a type, separated by a slash (/). The unique name is used for quick help (if you click and hold for a second, that name is displayed). It is also used for sending commands to the button from your script (for exampe to hide a button that is not allowed). Besides not having a slash or a vertical bar, the only other restriction is that prim names are limited to 64 characters. The unique name is used to identify the button and the type is one of the following 2 letter codes (always upper case, so far):
|DD||Drop Down button. Displays up to 8 faces when clicked the first time. On a second click the face touched becomes the only visible one and the corresponding sub-string from the descriptor is sent to all the prims in the build that the HUD is connected to. The format of the descriptor is a list of sub-strings separated by slashes (/). The number of sub-strings determines how many button faces are displayed, but the button prim should match this number. (There is no way to find out how many face a mesh prim has).|
|SB||Single Button. This button has only one face, you put a texture map on it, a unique name in the prim name followed by “/SB”. Put a string in the description. When the button is pressed, the prim name a equal sign (=) and the descriptor is sent to all the prims in the build the HUD is connected to.|
|CB||Color Button. Prim name is unique name followed by “/CB”. When clicked this button sends the color and texture UUID of the prim to the connected build, separated by an equal sign (=).|
|DC||Dynamic Color. Prim name is a unique name followed by /DC. You load the first face of the button with a name overlay, and put up to 7 colors and texture maps on the underlying faces. When one is selected, it sends the button name, color and texture UUID on the selected face to the connected build separated by equal signs.|
|SI||Single Instrument. Prim name is a unique name followed by “/SI”. Descriptor is a number an equal sign and a string. You load the button face with an icon or words. When clicked this button sends an “instrument message” to all the prims in the HUD and the connected build. Instrument messages are documented in the TestMast script. You can set up one of these buttons to furl a sail, set the throttle to a fixed speed, change the wind to a fixed direction, etc. Symbolic names for the instrument number and some value constants are understood.|
|DI||Dropdown Instrument. This is similar to a DD button, except the descriptor has pairs of instrument=value sub-strings also separated by slashes. When one of the drop-downs is selected the corresponding pair of instrument values is sent. Example: One DI button can be used to select sails to be furled, reefed or raised full.|
|MB||Mode Button. This button has multiple faces but does not drop down. Instead when clicked it sends the sub-string from the descriptor that corresponds to the currently visible face. The script on the build can ask the COM script to send a message to the HUD to change which face is visible (what mode it is in). Sub strings in the descriptor are separated by slashes.|
|HH||HUD HTML Help button. When you click on this button, it copies the URL out of the description to llLoadURL and opens your browser to that page.|
HUD Command button. When clicked, it executes the string in the description. Commands you can put in the description are:
page=n – Switch to page n of the HUD, n is 0 1 2 3 4 5.
set=button=value – Set the named drop down button to the named value
sync – Re-sync with the nearest boat.
exit – Detach from the avatar using the hud
hide=button – Hide and disable the named button
connect=n – Don't connect (n=0) or do (n=1) to boats that ask owners for OK
|DH||Dropdown HUD button. The selected dropdown is used to select the corresponding sub-string from the descriptor and execute it locally. Sub-strings in the descriptor are separated by a slash (/) character.|
|DB||Dropdown Boat button. The selected dropdown is used to select a sub-string from the descriptor to send as a command to the boat COM script. Sub_strings are separated by the slash (/) character.|
Button Slider. Click on the slider to send a short name and a number. Does not work while dragging, release and click again. Ex: Used for setting cannon powder charge (setting velocity of cannonballs). Format is:
Name: long name/BS
Sends your script a link message with num=MBFROMHUD and a string:
However, there is a way to send instrument message only to the HUDs, to initialize them after they sync. To do this you execute a line like this:
If id is NULL_KEY the list is sent to all the connected HUDs.
If id is the UUID of an avatar, only that avatars HUD gets the list.
String is a bunch of commands separated by newlines with the format:
The INSTNUM is one of the instrument commands converted to a number. Each button in the HUD that has the INSTNUM/value pair in its description has the corresponding face made visible. The HUD also repeats the message to any linked instruments with a call like:
Make sure you do not exceed the maximum length of 1024 characters allowed by llRegionSayTo, counting the header of 6 characters.
|MBsync--||Sent by a HUD that wants to connect to a COM script in a build. This is sent with llWhisper to every build within a 10 meter radius. All following messages are sent with llRegionSayTo so only the connected HUD or COM script will see them.|
|--MBack||Every COM script within 10 meters replies with this if it can connect. It only replies if the HUD is owned by the same person as the build, and if the description string in the HUD and in the COM prim match.|
|--MBwait||If the COM script is within range, has a matching descriptor, but is owned by someone else, it responds with this. Then it pops up a dialog and asks the owner of the build to give permission to connect. If the answer is yes, then it sends the MBack.|
|MBack--||The HUD waits for one second to see how many COMs reply, then it picks the one that is closest and replies with MBack to confirm the connection. In the case of a MBwait, it waits for the 'yes' MBack before sending this MBack.|
|MBping--||Every 30 seconds, the HUD sends this message to the COM to check and see if it is still there. The COM currently does not have a timer running to check if the HUD has not sent this recently, but what can a build do if you remove your HUD?|
|--MBping||The COM has one second to reply with the same message. If a second goes by with no reply, the HUD will start over with MBsync to try and connect again.|
When buttons of several types are clicked on the HUD, it sends a message like this. The format is Mbhud\nbutton_name=value=description where button_name comes from the button prim name. The value is different for different types of buttons and can just be a string from the button prim descriptor, a sub-string, a color, texture UUID, etc. The description is the description from the HUD, used by cannon to determine which sub-group of cannon the HUD controls. The COM script converts this message into a linked message and sends it to all other scripts in the build. The format of these messages is:
When this message is sent from the COM to the HUD it is followed by a list of commands to the HUD. The format of this is MBhud followed by a newline, a command, a newline, etc. Commands that are understood so far are:
sync –- The HUD starts the search to connect to a COM again
set=button_name=face –- The named button has its named face made visible
hide=button_name –- The named button is hidden and disabled
exit –- All the HUDs will detach from the avatars that are wearing them
connect=n – Don't connect (n=0) or do (n=1) to boats that ask owners for OK
control=n – Tell the HUD what to set the “boat will connect ...” button to.
The HUD wants to send a command to the COM script. The format of this is: MBcom\ncommand=value where command is one of the commands listed below and value is any parameter it needs. The commands currently understood are:
connect=n Refuse to connect to HUDs owned by others (n=0), ask your owner if this is OK first (n=1) or connect to any HUD withoug asking (n=2)
When the HUD detects an instrument sending an “instrument message” it converts it into a message sent to the COM, which converts it back into a linked message and sends it to all the scripts in the build. Also, there are button types that generate instrument messages directly. The format of this message is:
When the COM script detects an instrument message in your build, it converts it into a message sent to the HUDs, which converts it back into a linked message and sends it to all the scripts in the HUD build. If there is a drop-down instrument button with that number value combination in its description, the appropriate face of the button will become visible. This message allows lines sent back separated by newlines. Each line is just an instrument message number, an =, and the value for that command. Each line us converted into a call like: