Introduction
The rock pile is a group of large stones which are physical and can be pushed around by vehicles such as bulldozers. It is intended for use with the RezMela system.
Construction
Each rock is a separate mesh/sculpt prim, initially linked to the root object which controls them all. The root prim is not a rock, and does not become physical.
Each rock and the root prim contain the "rock pile" script; in addition, the root prim contains the RezMela "WorldObject root" script. The latter is a modified, backward-compatible version which allows delegation of deletion (see below).
All prims should have their PIN (set by llSetRemoteScriptAccessPin()) set to 1030.
Note that while the same script is used in the root prim and in the rocks themselves, the script behaves very differently depending on whether or not it's in the root. It is in effect two scripts combined into one for ease of maintenance.
Operation
On being rezzed, the rock pile script in the root prim (only) checks its start parameter, and if non-zero, assumes it has been rezzed by the RezMela system (as opposed to being manually rezzed to be worked on, for example). In that case, it waits a few seconds to allow all scripts to load, then unlinks the whole set.
The script in each rock, on being unlinked, sets the rock physical. Then it periodically checks to see if the rock has been pushed underground and if so, positions itself above ground again (this was found to be necessary when using the ODE physics engine with more than a few rocks in play).
The system continues in this way until the root script receives a signal from the "WorldObject root" script that the pile is to be deleted (see below). Then it broadcasts a signal to each of the rocks it started with (using osMessageObject()) which causes that rock to die; lastly it deletes itself.
Updating the rock pile script
For ease of updating, if the root script starts with a zero start parameter (ie not rezzed by the RezMela system), it copies itself to each of the child prims using llRemoteLoadScriptPin(). So updating the script for the pile only involves updating the copy in the root prim and waiting for copying to take place (there are messages in chat for this).
WorldObject root modification
Normally, the "WorldObject root" (here 'WOR') script deletes the object on receipt of certain commands from the control board. The added code for this project enables another script to assume responsibility for that deletion - which was necessary in this case because the unlinked rocks needed to be told to delete themselves. This is termed "delegated deletion" in the code.
To use this feature, the client script needs to send -7044001 as a link message to the WOR script, to tell it that it has assumed that responsibility. The WOR will then know to delegate deletion and at the appropriate time will send -7044002 instead of deleting the object. The client script should then do whatever is necessary and then delete the object.