Setting a Rezzed Object Timer

Before I commence with the main content a few words are due regarding a post in the SLED listserv from Eloise Pasteur, responding to the last post in this series, Rez Object Rotations. In this response El wrote:

WordPress hates me, otherwise I’d have commented directly.

It’s faster and neater in your code, whenever you can, to enter the quaternion directly. If you’re like me, you won’t learn any of them, or only a few anyway (I can do 90º rotations about a single axis in my head) but rather than struggling with it, if you drop the following script into a prim, rotate it as required and touch it, it will tell you its rotation as a quaternion so you can cut and paste.

El went on to provide a script which set the object name to My rotation is then on touching the object said the rotation in main chat.

My response to El was as follows:

Thanks El and you are correct. Having the quaternion entered directly saves the script time needed to calculate it from the X, Y and Z degrees. I’ll pop this all into the blog comments. For my part I was using the conversion to demonstrate creating a user-defined function but saving script time should be encouraged.

In the end I’ve popped this all in here, minus El’s script, because I wanted to supply an alternative script that doesn’t change the object’s name nor leave a touch_start event in the object if you forget to delete the script after getting the rotation. The following should be created in your Inventory (right click on the Scripts folder, select New Script and name it something like getQuatRot).

default
{
state_entry()
{
llSay(0, “The rotation is\n” + (string)llGetRot());
llRemoveInventory(llGetScriptName());
}
}

When dragged into an object’s Content area (i.e. its inventory) the script will say the object’s rotation as a quaternion that you can copy and paste into your code, then it will delete itself from the object.

For those that are rezzing an object that has only Copy permissions, i.e you can’t add a script, or that don’t want to use the scripted method above I have provided Isa’s Quaternion Rotation utility. This utility will say its rotation in main chat when touched, so it can be set to the X, Y and Z rotations you require then touched to provide the rotation.

Now on to the main topic of this post; setting up a timer for the deletion of a rezzed object.

The intent here is to demonstrate the last parameter of the llRezObject and llRezAtRoot functions and to show how it can be used to set a deletion timer for an object that has been rezzed using either function. The last parameter (see all parameter descriptions) is an integer, the value of which is passed with the rezzed object and can be retrieved from that object using the function llGetStartParameter or from within the event on_rez, an event triggered when an object is rezzed.

In this example the parameter is being used to set a time in seconds that the rezzed object remains inworld. Once the time is up the object is deleted. The rezzing object contains the following script, similar to those already described in this series. When touched it rezzes the object rezTest, using the function llRezAtRoot, at the same position as the rezzing object, with zero velocity, zero rotation and with the final parameter, an integer, set at 10.

default
{
state_entry()
{
}

touch_start(integer total_number)
{
llRezAtRoot(“rezTest“, llGetPos(), <0.0, 0.0, 0.0>, <0.0, 0.0, 0.0, 1.0>, 10);
}
}

The object rezTest has had the script below added prior to being placed in the Content area (inventory) of the rezzer. This script uses the event on_rez, the function llSetTimerEvent and the final parameter from the llRezAtRoot function to trigger the timer event.

On triggering the timer event the script then demonstrates the second way the final llRezAtRoot function parameter can be accessed; by using the llGetStartParameter function. This is converted to a string and sent out as part of a message into main chat. The timer event then uses the llDie function to delete the rezzed object rezTest.

The function llSetTimerEvent uses seconds, written as a float, as its parameter value. Because the on_rez parameter value is an integer, 0.0 is added so that it is created as a float. The final script for the object rezTest is as follows:

default
{
on_rez(integer start_param) // Triggered when an object is rezzed
{
llSetTimerEvent(start_param + 0.0); // Sets the timer event to trigger after 10 seconds
}

timer()
{
llSay(0, (string)llGetStartParameter() + ” seconds have passed”);
llDie(); // Deletes the object
}
}

The following show the two phases of the rezzed object.

Note: The deleted object does NOT return to your Inventory. It is permanently deleted.

In the next post in this series I will look at setting up a menu for choosing which object to rez from a rezzer containing multiple objects and how to replace one rezzed object with another.  Till then enjoy!

Next in this Series: Assembling the Holodeck

Advertisements

2 thoughts on “Setting a Rezzed Object Timer

  1. Pingback: Rez Object Rotations « F/Xual Education Services

  2. Pingback: Assembling the Holodeck « F/Xual Education Services

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s