Resizer

The Delta resizer is a script designed to use the updated in the 1.38 server API make fast resizing possible with just one script. It was developed at Delta to allow concurrent sizing of guns and holsters but can easily be used to allow users to resize other collections of objects.

1. What's in the box?

Start by rezzing the product box and clicking it to unpack it. You wil now have a folder called [Delta] Resizer containing:

  • The resizer script
  • A quick reference card describing the link messages used
  • A sample controller object
  • A sample slave object

The pack contains two very simple objects to show how it works; these are just one prim boxes, though of course the script works on link sets of any size. Rezz the two sample objects and click the controller (the black one). A menu appears that allows you to resize both objects.

Now you probably want to put the menu into something you made yourself.

2. Using the script

The script operates in controller or slave mode. In controller mode it displays a menu (see right) that allows the user to select the required size for an object and performs the resizing, passing on the choices to any listening slave resizers. In slave mode it listens for commands from a controller script in another object.


To size a single object, place the script in the object and wait for the ready message from the script before taking it into inventory. To start resizing you need to send a link message from another script. Here is a simple example of a script you could use to allow a user to resize a script by simply touching it.

default
{
    state_entry()
    {
      
    }
	
	touch_end(integer n)
	{
		if (llGetOwner() != llDetectedKey(0)) return;
		llMessageLinked(LINK_THIS,0,"RESIZE",llGetOwner());
	}
}

It's possible to set limits to the size change the user can make. The next script differs from the previous in setting a minimum of 50% of the original size and a maximum of 200%. Note that there is no protection agains resizing objects below the second life imposed minimum size; prims that have reached the minimum size will simply stay at that size.

default
{
    state_entry()
    {
      
    }
	
	touch_end(integer n)
	{
		if (llGetOwner() != llDetectedKey(0)) return;
		llMessageLinked(LINK_THIS,50,"RESIZE_MIN",NULL_KEY);
		llMessageLinked(LINK_THIS,200,"RESIZE_MAX",NULL_KEY);
		llMessageLinked(LINK_THIS,0,"RESIZE",llGetOwner());
	}
}

Finally an example with several objects. You need to select a channel on which the controller and the slave scripts communicate. Note that the scripts can only communicate if both objects are owned by the same avatar.

In this example we have two objects that use a chat channel to correspond. With the guns/holsters for which the script was designed, we already have to send messages from the gun to the holster (for example, to unhide the holstered version of the gun when the gun is holstered) and so we use the same channel to tell the holster that the user wants to resize. In this much simplified example (the prims for which are in the box) the user selects resize by clicking the white controller object.

First the controller script

integer sc=-90807;

default
{
    state_entry()
    {
    }
    
    touch_end(integer n)
    {
        if (llGetOwner() != llDetectedKey(0)) return;
        llMessageLinked(LINK_THIS,50,"RESIZE_MIN",NULL_KEY);
        llMessageLinked(LINK_THIS,200,"RESIZE_MAX",NULL_KEY);
        llMessageLinked(LINK_THIS,0,"RESIZE_MENU",(key) "-20,-10,-2,2,10,20");
        llMessageLinked(LINK_THIS,sc,"RESIZE",llGetOwner());
    
    }
    
}

Now for the slave

integer sc=-90807;

default
{
    on_rez(integer n)
    {
        llMessageLinked(LINK_THIS,sc,"RESIZE_SLAVE",NULL_KEY);
    }
}

Note that in our example the slave object is permanently in slave mode. We don't recommend this. Firstly it increases the risk of cross talk if the user resizes some other object with the same script, and secondly it leaves an open listen. It's better to arrange to start the slave script when needed and then use the RESET_COMPLETE link message to stop it.

3. Link message reference

RESIZEStart a resize session in the controller
RESIZE_SLAVEStart a resize session in the slave
RESIZE_MAXSet maximum allowed percentage of original size. The integer parameter is the percent which should obviously be more than 100.
RESIZE_MINSet minimum allowed percentage of original size. The integer parameter is the percent which should obviously be less than 100.
RESIZE_MENUSet percentage changes to be offered on the menu; use a comma separated list of integers
RESIZE_MESSAGESSet the four messages shown to the user: these by default are: Resizing, please wait, Resize complete, Cannot make object any smaller, Cannot make object any larger. Supply four messages separated by the vertical bar character as the key argument.
RESIZE_ENDThis message is sent by the resize controller when the user clicks End. It can be used to tell slave objects to send RESIZE_COMPLETE messages to the slave scripts.
RESIZE_COMPLETEThis message tells the slave script to stop communicating with the controller. This saves a listen and also avoids the danger of the slave object resizing by accident when another object is resized.

4. Technical note

The script remembers the size of each prim when it is reset. If you change the model in any way you need to reset the script. When the user selects an option all prims are scaled by the appropriate factor. Note that prims for which one of the dimensions reaches the minimum allowed size will continue to scale but with that dimension fixed at the minimum size, and so will become distorted. However, because the script remembers the original size, if the object is scaled up again the distortion will not be magnified. Reset will always return the object to its exact original scale. (The script can be quite a useful tool for shrinking objects that refuse to go any smaller in the editor).

Percentages are calculated from current not from original size. So if you shrink an object by 10% and then enlarge it by 10% it will still be smaller than it started out.

Communication between controller and slave uses llWhisper, so any slave objects must be within 10m of the controller.

4. Licence

The script is provided copy, transfer, no mod. You may include the script in a product of your own to allow your users to resize components of that product. You may not resell or give away the script as a tool for other builders to use.


Change log

v1.0
  • Release