Don't click here unless you want to be banned.

LSL Wiki : RecursiveRezzing

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl411.us.archive.org

Recursive Rezzing


(Sorry this isn't pretty yet. I'm just starting to use the Wiki and don't have all the formatting down.)I formatted the code snippets for you.-DolusNaumova

To make objects reproduce themselves, they have to rez a copy of themselves. The fastest way to do this is to place a copy of the parent object (including its running scripts) back into itself and then use llGiveInventory to copy the parent to the child for the child to copy on down the line.

One drawback to this during development is that every time you change the parent, you have to reinsert the child back into the parent to update the code that it contains. This is sort of a chicken-and-egg game that is both time consuming and mind-bending.

The other problem this creates is that if you are building on your object, every time you rez it, it will start to do its thing since the script has to be running.
This can be alleviated if you give every child object a non-zero parameter when calling llRezObject. Then in the object check the start_param in on_rez; if zero then don't run, if non-zero then act normal. This doesn't stop the chicken/egg annoyance during testing though. -NeverRust

In order to avoid these problems, and keep most of the script separate from the object in the parent, you can do this:

1. Make your object. Put a simple script in it like this:
default
{
    state_entry()
    {
     llSetRemoteScriptAccessPin(foo);
    }
}

where foo = an integer and not an actual variable.
You never have to change this script unless you want to change the PIN.

2. Create a rezzer object that will rez the first instance of the thing that will grow. It has a separate rezzer script in it that includes this:
default
{
    touch_start(integer total_number)
    {
        llRezObject("Object Name", <x, y, z>, ZERO_VECTOR, ZERO_ROTATION, param);
    }
    
    object_rez(key child) 
    {
        // Give inventory items. This way the script doesn't have to be running in the rezzer.
        llGiveInventory(child, "Object Name");
        llRemoteLoadScriptPin(child, "Object Name Script", foo, TRUE, param);
    }
}

<x, y, z> is the position vector you define for the child to start at
param is a parameter to be passed to the child
foo is the SAME integer you put into the actual object pin setter.
llRemoteLoadScript will start the script after it is received.
Add one llRemoteLoadScript call for each of the scripts the child should have (EcoName definitions, locomotion, etc.)

3. The code in the script that makes the object reproduce has similar llRezObject code triggered by whatever you decide should allow the object to reproduce. It also needs the SAME object_rez event handler as is in the rezzer.

4. Put the object with the PIN script into the rezzer object along with the rezzer script and the object's reproduction script. Now you can start a new round of objects. No muss, no fuss.


Ecosystem | Rez
There is no comment on this page. [Display comments/form]