CHAPTER 4
THE PRESTO,
ABRACADABRA
OF REZZING
CONTROLLING
MOTION OF
NONPHYSICAL
OBJECTS
SUMMARY
100
THE PRESTO, ABRACADABRA OF REZZING
Rezzing is the creation of a new object in-world. You are already familiar with manual creation of objects;
scripting this process gives you additional flexibility and power in any situation where you have build
privileges. This section presents a few examples of how to automatically rez and control objects—including
how to cheat on your prim budget.
A few caveats do apply. For example, a rezzed object must already exist in the inventory of the rezzing
object. That is, you can rez a basic object that you have in inventory and mutate it, but unlike the build tool
in-world, a script needs to start from something. The rezzing object must have full modify permissions on
the rezzed object. Additionally, LSL does not allow you to create new LSL scripts automatically.
LOOP REZZERS
One thing we all know from firsthand experience is that making large numbers of repetitive objects is a
huge pain. Anyone who has ever made skirts or hair or any other artifacts with large numbers of prims has
certainly experienced the pain. Fortunately, a class of scripts generically known as loop rezzers has evolved
to handle the creation of a large number of similar objects, such as skirts, flower petals, spiral staircases,
and sculptures. You can find some excellent examples of loop rezzers in-world, including a very nice one
offered freely at Vint's primskirtbuilder sandbox, Mindulle <231, 152, 125>.
Loop rezzers can be used as the basis of your own projects. Often, loop rezzers delete themselves
after they have rezzed the more complex object. Other rezzers can play a more active part in the life cycle
of their rezzed items. The next few examples illustrate how to use these automatic loop rezzers.
Making a Flower with a Loop Rezzer
Listing 4.1 illustrates a loop rezzer that creates a flower complete with petals. Put it inside the root prim.
For this flower, that would probably mean the "eye" of the flower head. Note that this script doesn't
actually link the prims together, so you could always delete the "generator" prim after the autogeneration
has completed. This kind of script is extremely useful in place of finicky builds that need prims to line up
exactly: you can do all the math in the script, rather than manually.
Listing 4.1: Flower Loop Rezzer
integer gNumPetals = 8; // how many objects
list gPetals = [];
integer gCmdChannel = 990;
integer gCmdPetalChannel = 991;
makePetals() {
integer petal;
float basicAngle = (360.0 / gNumPetals) * DEG_TO_RAD;
float deltaRot = 0.0;
vector currPos = llGetLocalPos();
rotation rootRot = llGetRootRotation();

Get Scripting Your World: The Official Guide to Second Life® Scripting now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.