Main controllers

This page describes two controller scripts that are used directly (not from another system): how to install them, use them and configure them.

MVTP_TouchStartStop

The MVTP_TouchStartStop script is a very simple controller script that is full perm and only 13 lines long (counting lines with a single curly brace)!

It is as simple as it can be: when someone touches the object, the motion starts, and stops when the object is touched again.

To use it:

There is nothing to configure in the MVTP_TouchStartStop script as it is, but it can be easily modified to add, for example, access control.

MVTP_GeneralController

On the Simple setup and testing page, we already described some features of the MVTP_GeneralController script. Let's sum things up and address features not mentioned previously and how to configure it.

This script has evolved from the SimpleControl shipping with earlier versions of the MvtPlayer. It allows two kinds of control:

Both control systems can be individually enabled or disabled through a simple switch in the script. Everything is configurable, from menu text and button labels to access control, timeouts and details regarding the remote control interface.

The menus

Here is a quick summary of the menu (again, please refer to the Simple setup and testing page for more information about this):

Remote control interface

If it's enabled (see below), the script will listen to commands on a private chat channel (12 by default) for commands. These commands give access to all required features and can be used either directly (by typing the command in the viewer's chat bar, e.g. /12menu) or as sent by another object (rezzed remote or HUD, typically). Shipping with the MvtPlayer are two examples of remote control scripts (see below).

The expected syntax is rather straightforward: use, in this order, a message composed of the following elements separated by | (vertical bar, but this can be changed):

Known commands are case-insensitive:

As mentioned above, the MENU commands supports a menu level (identifier) as argument:

Here are a few example commands. They use 12 as channel number and | as separator but remember this can be changed in the script.

Remote control scripts

The scripting reference page has all the required information to build your own remote controller. Here we will only be talking of the remote scripts provided with the MvtPlayer itself. They all require that the MVTP_GeneralController is installed inside the moving object, and properly configured.

MVTRemote_Trivial

As the script name implies, this is a very simple script (7 lines of code including braces) used mainly as an example. Its job is to open the main menu as soon as someone (who is allowed to use it) touches the object.

MVTRemote_Detection

This special remote control script is used to trigger a movement (actually: send a command to the MVTP_GeneralController script) when an avatar is detected by another prim. Great for scaring people who get too near!

The detection itself can be done in three ways:

A few parameters are available near the start of the script. The script itself is rather simple and can be modified in several ways to fit your exact needs if you have some basic scripting knowledge.

integer remote_channel=12;
string remote_separator="|";

These two parameters deal with the communication protocol and should be se to the same values as in MVTP_GeneralController.

string command_main="start";
string command_extraargs="";

These settings define which command is sent when someone is detected. It should probably be the start command and the extra arguments, if any, be the required playback options.

string nonecommand_main="stop";
string nonecommand_extraargs="";

These define the command sent when no one is detected in range. It should definitely be a "stop" command, or just nothing if your sequence does not automatically loop.

Since there is not really a reliable way to detect when someone has stopped colliding with a prim, this setting is only used with the sensor detection, not collisions.

Next we have the settings for the sensor detection:

float sensor_range=2.0;

float sensor_arc=PI;

float sensor_rate=1.0;

They tell if the sensor is to be used at all, how far (in meters), along which angle (in radians) and how often (in seconds) it should detect people. For more information (with nice graphics) about how sensors work please refer to this page.

Finally there are a few settings dealing with the collisions:

integer use_collisions=FALSE;

This defines if collisions will be considered (TRUE) or not (FALSE). It does not make much sense to use both the sensor and collisions at the same time, but it's technically possible.

integer use_volumedetect=FALSE;

This setting defines if regular collisions are used (FALSE) or if volume detection will be used (TRUE). For some explanations about the difference please refer to this page.

string collision_sound="";

float collision_volume=1.0;

Here you get the opportunity to set a specific collision sound (by UUID or inventory name) and its volume (between 0.0 and 1.0) or to leave the default sound.

MVTRemote_Buttons

The MVTRemote_Buttons is a more complex [than MVTPRemote_Trivial] remote control script that allows for several buttons to send orders to the MvtPlayer. based on the prim names and maybe their faces being touched.

Drop it inside the root prim of your remote control object or HUD, and make sure to assign the correct commands to the correct buttons.

Here is a summary of the available settings inside MVTRemote_Buttons:

As an example, consider:

list commands=[
"main menu:5","MENU|0", // open the main menu
"play","START|VOLUME=0.0",
"stop","STOP"
];

This list defines three buttons:

Of course the script will send the toucher's UUID as part of the command so it's actually the person using the remote that will be checked for access control and will get the menus, as expected. Therefore you must not specify the specific UUID part (2nd one), as in the examples above.

Customizing MVTP_GeneralController

All available settings are grouped at the start of the script, and divided into sections to make things easier. Moreover, many comments whill help you enter the correct settings into the script.

Section: Notecards

There is only one setting in this section: 

string notecard_prefix=".";

This is used to filter out any notecards whose name does not start with the required prefix when prompting which config to load. It's a convenient way to restrict the user's choice to only meaningful notecards: no more loading an AVPos notecard as a movement configuration notecard for example, if you require them to start with a leading dot.

Also note that when presented as buttons in a menu to the use, the prefix will be stripped, too.

Section: Access control

Access control here means to decide who is allowed to use the script and who will be denied access, be it from a direct menu or remote access. It is mainly decided by a setting called allowed:

integer allowed=0; // access rights: 0=everyone, 1=group, 2=object owner, 3=white list

As implied by the comments, it can take 4 values from 0 to 3. 0 means that everyone can use the controller without restriction. 1 means that only people wearing the same group tag as the prim containing the script will be allowed. 2 means only the object owner will be allowed, and finally 3 means that only people explicitely mentioned in the white list will be allowed.

The white list itself is defined in the next lines, and is only used if allowed=3:

list whitelist=[
"Oggy Fink",
"oggy2"
];

You can of course add any number of names to this list. Its elements may be either Legacy names, user names or UUIDs. In all cases, beware of the spelling and character case!

People being denied access may get a message from the script; this message is mentioned in the localization section below.

Section: Menu definitions

This section contains settings for the menu definitions.

integer touch_allowed=TRUE; // if set to FALSE the menu will NOT trigger when the object is touched

This setting decides if the menu will open at all when someone touches the object. If set to FALSE, it is still possible to use remote commands, including to open the menu. It's just the touch that is deactivated.

Then come the menu prompts and buttons for every menu managed by the script. I will only mention a few setttings about the main menu here, please refer to the comments for the details about other menus.

string level0_prompt="Please select what to do now.\n\nLast status: [last status]";

The level0_prompt is the text used inside the dialog box. The \n codes are newline characters used to split the text among several lines. One noteworthy part is the [last status] special code, which will be replaced by a human-readable version of the last status code sent by the MvtPlayer, if known.

list level0_buttons=["Select config","Start","Stop","Pause","Resume","PluginWake","Version","Web site","Playback opt.","Close menu"];

This is the list of buttons for the main menu. You are free to modify them but keep in mind that their length will be limited as it is an SL limitation. And make sure they are unique, of course.

integer menu_reopen=TRUE; // should the menu automatically reopen after selecting an item?

This setting indicates if the menu automatically reopens after being used (unless the "Close menu" button was hit, of course), or not.

float menu_timeout=60.0; // the menu will stop responding after this number of seconds (set to 0.0 to disable)

This setting defines the amount of time after which the menu will stop responding, as an anti-lag measure.

Section: Remote control

Settings in this section deal with the remote interface part of the script.

integer remote_channel=12; // the channel number to listen to. Set to 0 to disable the remote control features

This important setting is the channel number for the remote commands. You can use any non-zero number, depending on what you want to do. Small positive values like 12 make it easy for the end user to send direct chat commands, while very negative values like -568110 are a better choice for communicating objects like HUDs and rezzed remotes. Of course, make sure your object or HUD is configured to use the same channel, too.

string remote_separator="|"; // | is a sensible choice of a separator, but a newline \n can be a good choice too for objects

This defines the character (or characters) used to separate parts of a remote command. | is a nice choice as it is probably non-ambiguous (unless a notecard name or plugin wait messages uses one!) and perfectly usable to the end user in a chat command. Another sensible choice would be \n because that make it impossible from the viewer window while being usable for scripts, and notecard names cannot contain newline characters. Again, make sure your remote control script uses the same setting.

Section: Localization

The localization section defines every text presented to the user so that it can be changed, maybe to use the script into your own language.  Please refer to the comments in the script to understand the meaning of every setting.