MiceOnABeam Product Documentation

Modified: 4/25/2013 8:23 PM
Recently changed articles You can subscribe to this wiki article using an RSS feed reader.

10 Steps to Creating Your First MiceOnABeam Script

Program Overview & Menus Previous   NextModeling Overview

Getting started with MiceOnABeam is straightforward. An overview of the steps involved in creating an LSL script is provided here.

Step 1: Learn the basics

Note that this documentation is not intended to be a tutorial on the LSL scripting language. While MiceOnABeam significantly simplifies your use of LSL and generates much of the scripting code, you should still become familiar with the basic concepts of LSL such as variables, datatypes, functions, flow control statements and events.

If you're not familiar with these please check out wiki.secondlife.com/wiki/Help:Getting_started_with_LSL or review the other introductory tutorials at the LSL Portal (wiki.secondlife.com/wiki/LSL_Portal).

In addition there are three key MiceOnABeam modeling features that you must become familiar with, namely the State, the Transition and the Choice Point. In many cases these modeling components will be all you need to create your script. Check out Modeling Overview to get up to speed here.

Step 2: Create a new script model

From MiceOnABeam's File menu, select New.... Then enter a name for your new script and click on the OK button. This will create a new State Editor window in which you will design your script model.

Step 3: Design the states for your script

The first step in the design is to break down your script's logic into one or more states.  States represent the major modes of your script. Each state represents a point in time where your script is waiting for a specific set of things to happen, called events, in your virtual world. Each event type can be handled in a different way depending on which state your script is in when the event is received.

To create a new state select the State icon   in the tool palette and then click within the State Editor at the location where you want the new state to appear. You can then rename, resize and move the state as desired.

Step 4: Specify the events that your script will respond to

To specify an in-world event that your script will respond to, you use a transition which is represented by an arrow line. To create a new transition select the Transition icon  in the tool palette and then click and hold the mouse button within the State Editor on the state in which the event will occur. Then drag the mouse over to the state that you want your script to be in after processing the event (which can be the same or different state).

To assign an event to the transition, you must open the Properties Editor for the transition by right-clicking over it and selecting Edit Properties from the menu. Then choose the desired event from the drop-down list.  You can also optionally set a Guard Condition (which must be an LSL expression that returns TRUE or FALSE) to enable or disable the handling of the event.

Don't forget to create an Initial Transition from the Initial Point to the starting state for your script, otherwise your script won't know which state to start up in, and will simply terminate when run.

Step 5: Specify what should happen when an event occurs

Once an event occurs you will naturally want your script to perform one or more actions to effect changes within your virtual world before moving to the next state and waiting for another event. These actions can be specified in several places in your MiceOnABeam model, such as within the transition itself (Transition Action) or within a state (Entry and Exit Actions).

All action code is entered within the Properties Editor of the corresponding state or transition (right-click over the component to open it's Property Editor). Code can also be entered in global or scoped functions that can be defined.

To enter in action code you have two options:

  • Use the LSL Actions feature to select one of the built-in actions provided in MiceOnABeam, or

  • Insert your own LSL code directly.

After entering in your action code in the Properties Editor select the OK button to close and save your changes. Any LSL coding errors will be immediately highlighted for you to fix.

Note that you can also document your script model by entering in a textual comment for each modeling component. To create a comment right-click over a modeling component and select Edit Comment from the menu. To easily view your comments select the Show Info icon  in the State Editor's toolbar and then move the mouse cursor over to the components of interest.

Step 6: Save your script model

From MiceOnABeam's File menu, select Save. Then enter a name for the model file and click on the OK button. This will save your model within the MiceOnABeam\Scripts folder of your documents folder.

Step 7: Set your debugging options

Once you've created the first draft of your script model, you'll want to test it out within your virtual world. To help you here MiceOnABeam provides special debugging features to help you.  From MiceOnABeam's Tools menu, select Options, and then click on Code Generation. Select one or more of the built-in execution tracing options and then select the OK button.

Step 8: Generate the LSL Script

You then generate the LSL code corresponding to the model by selecting Generate LSL... from the Script menu. A window will open up containing the generated code. You simply select the Copy button to copy the code and then paste it directly into your virtual world's scripting editor.

If there are coding errors a Code Generation Errors window will be displayed listing each error. Simply double-click an error to go directly to the place within your script model where the error was found.

If you're using Second Life, ensure that the Mono checkbox is selected at the bottom of the SL editor, and then click the Save button. Ensure the Running checkbox is selected, and your MiceOnABeam generated script should now be running.

Step 9: Test & Iterate

Test your script in your virtual world, running through all possible events and situations that your script may encounter. When you need to make a change back in your MiceOnABeam model, make the change and simply press CTRL-g to generate the LSL script and automatically copy it to the system clipboard so that it's ready for pasting into your virtual world's scripting editor.

Note that the latest software development strategies advise that you add functionality to your script in small increments, testing at each iteration. In this way you will always have a working version of your script and can more easily back out a change that hasn't worked out.

Step 10: Optimize & deploy the generated code

After all your testing is completed and you are ready to deploy your new script, select Generate LSL (Optimized)... from the Script menu. This will generate a script for the model without any system-generated comments and as well perform several optimizations in the code. You can also select the Code Generation option to exclude comments that you have entered in the code for a more compact script.

Next Steps

If you haven't already checked out Modeling Overview please do so now in the next section. It provides an overview of the three key modeling features that you will use to create your model. Following which try out the online Tutorial for a step-by-step creation of a script model. For more comprehensive tutorials see the video series: MiceOnABeam Basics.

Experienced scripters should review the Modeling Features section for full detailed descriptions of all modeling features together with usage scenarios.

If you're familiar with the Unified Modeling Language you might also wish to review Comparison with UML 2.0 State Machines for a list of the UML State Machine concepts that are supported by MiceOnABeam, together with descriptions of any conceptual changes or restrictions that have been made.

Program Overview & Menus Previous   NextModeling Overview

Home: MiceOnABeam Product Documentation Copyright © 2010-2018 MiceOnABeam Software