277
14
Scripting Basics for the Designer
There should be no such thing as boring mathematics.
Edsger Dijkstra
14.1 INTRODUCTION TO SCRIPTING IN LSL
Just as movie actors need scripts to exchange dialogue with other actors and guide their actions on set, a
virtual environment needs scripts written in a programming language to bring animation and interactivity to
its vehicles, buildings, furniture, vegetation, and animals. Inside the contents of a chaise lounge, entry door,
or a vehicle are scripts that communicate with the avatar, the server, and the client viewer. These scripts are
programs written in languages such as Linden Scripting Language (LSL) for Second Life or OSSL, which is
an API (Application Programming Interface) extention of LSL made for worlds based on OpenSim. In Unity,
languages such as UnityScript, C#, or Boo are used, and you can code in C# for OpenSim as well.
Although scripts are an essential component to most virtual environments, they often present a seemingly
inaccessible workspace for designers with little or no background in computer programming. In this chapter,
the basic elements of a script are discussed, and samples of a few starting scripts are analyzed to help you, the
designer, embark on your own path of discovery about scripting. If you are designing a more advanced virtual
environment that involves complex interactive elements, you should consider hiring a scripter (or coder) to
write the scripts you need. Guidelines about collaborating with scripters are provided in Section 14.6. Also
included in this chapter are various sources online for pre-written scripts which you can adapt for your designs
in Second Life and OpenSim.
14.2 DESIGN THINKING AND SCRIPTS
The idea of referencing and running a script program on the server from a 3D object in a virtual world may
seem unusual to your designer’s frame of mind, but in fact scripts are used by lots of virtual world content,
and can easily become part of your design thinking.
14.2.1 seTTing design goals for a sCripTed enVironmenT
Good design of script-lled environments starts with a clear set of goals. Let’s suppose you wanted to build
an Art Park in a virtual world. Start thinking about how scripting is incorporated into your design by asking
the following questions:
1. What are the primary needs for scripting in this environment?
2. What are the secondary needs for scripting in this environment?
You might dene the primary needs as: (1) avatar interaction with seating and viewing, (2) avatar
inter action with signage and media on the sim, and (3) avatar movement to all parts of the environment.
278 Virtual World Design
Scripted objects used for these primary needs are the benches and seats in the viewing areas, various
interactive signs and boxes to give the visitor informative note cards from the exhibits, and transportation
devices (often teleporters, sometimes tour vehicles) that help the avatar move about, especially in a large
virtual environment.
Now, what about secondary needs? To dene them, consider these questions:
1. What if some of your artworks were interacting with real-time data gathered online?
2. What if your artworks “interacted” with the visitor, creating sound, movement, or other changes in
response to their presence?
These secondary needs can directly affect the visitors’ experience with the artworks in your Art Park
andgreatly enhance their understanding of your message. So, how do you decide what gets scripted in your
Art Park? The essential questions to ask are the following:
1. What experience can be created for the visitor by using scripts?
2. How can scripted objects enhance that experience?
3. How can this environment be made more accessible to all through scripting?
Remember to consider “Design for All” access in your planning, with signs that can talk as well as be
read, paths that guide with sound as well as directional pointers, and tour vehicles that give narration in
sound and notes.
14.2.2 Building a reaCTiVe enVironmenT
In a virtual world, architecture can take on a life of its own. Jon Brouchoud (Keystone Bouchard in Second
Life) creates spaces with “reexive architecture” and interactive forms. These structures react to an avatar’s
presence by changing properties, such as their scale, form, opacity, and color. If you are thinking about design-
ing a building that has the capacity to move, change, and evolve its shape, you cannot help but develop an
awareness of how the scripts inside the building elements will be working and how they relate to the linked
structure of the building itself. In Figure14.1, a “twist response” script developed by Keystone has been loaded
into some brick columns, and, as you can see, the proximity of an avatar causes the columns to twist up.
As a designer, you also need to think of the interaction between an avatar and the virtual environment,
not only the “reaction” of the objects to the avatar’s presence, but the “interactivity” that a scripted design
engenders. The plasticity of a virtual environment creates both design opportunities and complications for
you in this regard. On the one hand, you could design a living room that rearranges its furniture to suit the
owner’s needs for space, but on the other hand, you may nd an automatic furniture-arranging living room
does not fully suit the very human need to be “hands on” when personalizing an owner’s environment. Haptic
technology is creating ways to let us touch and feel virtual objects but is still in its early development stages.
For the time being, we still rely on screen-based graphic and textual interfaces to control and manipulate the
objects and their properties in our designs. Make the following observations as you learn about scripting and
plan for its inclusion in your virtual environment designs.
1. What interactive opportunities am I seeing in this virtual environment?
2. What are avatars doing with this designed environment that I did not expect?
3. Have I seen avatars playing games with available content not intended for gaming purposes or
hacking/modifying it in some way?
279Scripting Basics for the Designer
These observations provide valuable insight into how interactivity can be developed and enhanced.
Humans, and the avatars they inhabit, have a fundamental need to interact with their environment, and a
good designer utilizes this to make his or her scripted designs part of a powerful and immersive environment.
14.3 AN OVERVIEW OF HOW LSL SCRIPTS WORK
Because writing commands out in binary or even machine language is cumbersome at best, we have devel-
oped programming languages like C, C++, C# (pronounced “C sharp”), Java, and so on to enable our com-
munication with the computer. The scripting languages used in Second Life and OpenSim (LSL and OSSL)
are related to, but different from, programming languages like C, C++, C#, or Java. LSL language and the
scripts made from it are designed to help you communicate with the server about the things you would like
your content to do, in a way that is easier to understand, manage, and modify.
There is a pivotal scene in the Wizard of Oz, the 1939 MGM lm, when Dorothy discovers that the “great
and powerful Oz” is just a middle-aged man pulling levers on a machine behind a curtain. Dorothy quickly
comes to the realization that she could just as easily control these magical devices, and suddenly the whole
status of Oz changes in her mind. People who write the scripts in virtual worlds may seem like wizards.
Letus pull the curtain back, look at their tools, and try running the magic ourselves.
A script is really just a set of instructions that is running on the server and referenced by your content.
Youhave probably seen a similar thing in real life. For example, look at this snippet of a script you might
write for a movie scene.
Dorothy: Wow! That is some magic-making machinery you have there! [She moves forward.]
A script for objects in a virtual world shares several characteristics with that bit of screenwriting: (1) It
identies what (or who in this case) is directed to do something, and (2) it denes what that thing or person
FIGURE 14.1 Screen grab from OpenSim showing architectural columns with “twist response” reexive scripting,
developed by Jon Brouchoud (Keystone Bouchard in Second Life). The LSL script makes them twist in response to
avatar proximity.
280 Virtual World Design
should say and do. A script in a virtual world, like a movie script, also has a specic structural format. It also
utilizes color-coded text to identify its key components for easy reading.
Just as a movie script uses capitalization, indentation, and parentheses to let the reader quickly differen-
tiate between who is speaking, what they are saying, and what they are doing, a virtual world script uses
indentation and curly brackets {and} to identify its components and allow the scripter (coder) to keep track
of what goes on in it.
14.4 ABOUT THE SCRIPT EDITOR
Fasten your seatbelts and turn on your brain. Log in with the Firestorm Viewer, and go to a sandbox or some
land where you have build permission. Let’s go ahead and create a few basic scripts inside of an object by
using the new script button in the Build menu. When you double click on a script within the contents of an
object, the Script Editor menu will let you examine the actual code of the script itself.
14.4.1 your firsT sCripT
We start this section by creating a cube. There are samples of basic scripts in the next sections for both
Second Life (Table 14.2) and OpenSim (Table 14.3), so the world in which you start really doesnt matter.
Figures 14.2 and 14.3 illustrate the process.
1. Activate the Build menu on the top bar of your viewer. Rez a cube and look down at the tabs in the
Edit menu that appears. Find the last tab over, the Content tab as shown in Figure14.2. Open the
Content tab and click the New Script button.
FIGURE 14.2 Screen shot from OpenSim, showing the process of adding a new script into a cubes content. Note how
the object now says “Script running” to you in local chat as it runs the script.
281Scripting Basics for the Designer
FIGURE 14.3 Screenshot of new script creation in OpenSim environment, shown within the Script Editor. Double
click on the new script in the contents of an object to open the Script Editor.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset