Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Building Linkset_Resizer  

Linkset_Resizer

Linkset_Resizer

Category: Building
By : Brilliant Scientist
Created: 2010-11-16 Edited: 2010-11-16
Worlds: Second Life

the Zip file

Download all files for Linkset_Resizer
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Linkset_Resizer_1.lsl
1 // Linkset Resizer with Menu
2 // version 1.00 (25.04.2010)
3 // by: Brilliant Scientist
4 // --
5 // This script resizes all prims in a linkset, the process is controlled via a menu.
6 // The script works on arbitrary linksets and requires no configuration.
7 // The number of prims of the linkset it can process is limited only by the script's memory.
8 // The script is based on "Linkset Resizer" script by Maestro Linden.
9 // http://wiki.secondlife.com/wiki/Linkset_resizer
10 // This script still doesn't check prim linkability rules, which are described in:
11 // http://wiki.secondlife.com/wiki/Linkability_Rules
12 // Special thanks to:
13 // Ann Otoole
14
15 float MIN_DIMENSION=0.01; // the minimum scale of a prim allowed, in any dimension
16 float MAX_DIMENSION=10.0; // the maximum scale of a prim allowed, in any dimension
17
18 float max_scale;
19 float min_scale;
20
21 float cur_scale = 1.0;
22 integer handle;
23 integer menuChan;
24
25 float min_original_scale=10.0; // minimum x/y/z component of the scales in the linkset
26 float max_original_scale=0.0; // minimum x/y/z component of the scales in the linkset
27
28 list link_scales = [];
29 list link_positions = [];
30
31 makeMenu()
32 {
33 llListenRemove(handle);
34 menuChan = 50000 + (integer)llFrand(50000.00);
35 handle = llListen(menuChan,"",llGetOwner(),"");
36
37 //the button values can be changed i.e. you can set a value like "-1.00" or "+2.00"
38 //and it will work without changing anything else in the script
39 llDialog(llGetOwner(),"Max scale: "+(string)max_scale+"\nMin scale: "+(string)min_scale+"\n \nCurrent scale: "+
40 (string)cur_scale,["-0.05","-0.10","-0.25","+0.05","+0.10","+0.25","MIN SIZE","RESTORE","MAX SIZE","DELETE..."],menuChan);
41 }
42
43 integer scanLinkset()
44 {
45 integer link_qty = llGetNumberOfPrims();
46 integer link_idx;
47 vector link_pos;
48 vector link_scale;
49
50 //script made specifically for linksets, not for single prims
51 if(link_qty > 1)
52 {
53 //link numbering in linksets starts with 1
54 for (link_idx=1; link_idx <= link_qty; link_idx++)
55 {
56 link_pos=llList2Vector(llGetLinkPrimitiveParams(link_idx,[PRIM_POSITION]),0);
57 link_scale=llList2Vector(llGetLinkPrimitiveParams(link_idx,[PRIM_SIZE]),0);
58
59 // determine the minimum and maximum prim scales in the linkset,
60 // so that rescaling doesn't fail due to prim scale limitations
61 if(link_scale.x<min_original_scale) min_original_scale=link_scale.x;
62 else if(link_scale.x>max_original_scale) max_original_scale=link_scale.x;
63 if(link_scale.y<min_original_scale) min_original_scale=link_scale.y;
64 else if(link_scale.y>max_original_scale) max_original_scale=link_scale.y;
65 if(link_scale.z<min_original_scale) min_original_scale=link_scale.z;
66 else if(link_scale.z>max_original_scale) max_original_scale=link_scale.z;
67
68 link_scales += [link_scale];
69 link_positions += [(link_pos-llGetRootPosition())/llGetRootRotation()];
70 }
71 }
72 else
73 {
74 llOwnerSay("error: this script doesn't work for non-linked objects");
75 return FALSE;
76 }
77
78 max_scale = MAX_DIMENSION/max_original_scale;
79 min_scale = MIN_DIMENSION/min_original_scale;
80
81 return TRUE;
82 }
83
84 resizeObject(float scale)
85 {
86 integer link_qty = llGetNumberOfPrims();
87 integer link_idx;
88 vector new_size;
89 vector new_pos;
90
91 if(link_qty > 1)
92 {
93 //link numbering in linksets starts with 1
94 for (link_idx=1; link_idx <= link_qty; link_idx++)
95 {
96 new_size = scale * llList2Vector(link_scales, link_idx-1);
97 new_pos = scale * llList2Vector(link_positions, link_idx-1);
98
99 if(link_idx == 1)
100 {
101 //because we don't really want to move the root prim as it moves the whole object
102 llSetLinkPrimitiveParamsFast(link_idx, [PRIM_SIZE, new_size]);
103 }
104 else
105 {
106 llSetLinkPrimitiveParamsFast(link_idx, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);
107 }
108 }
109 }
110 }
111
112 default
113 {
115 {
116 if(scanLinkset())
117 {
118 //llOwnerSay("resizer script ready");
119 }
120 else
121 {
123 }
124 }
125
126 touch_start(integer total)
127 {
128 if(llDetectedKey(0) == llGetOwner()) makeMenu();
129 }
130
131 listen(integer channel, string name, key id, string msg)
132 {
133 //you can never be too secure
134 if(id == llGetOwner())
135 {
136 if(msg == "RESTORE")
137 {
138 cur_scale = 1.0;
139 }
140 else if(msg == "MIN SIZE")
141 {
142 cur_scale = min_scale;
143 }
144 else if(msg == "MAX SIZE")
145 {
146 cur_scale = max_scale;
147 }
148 else if(msg == "DELETE...")
149 {
150 llDialog(llGetOwner(),"Are you sure you want to delete the resizer script?",
151 ["DELETE","CANCEL"],menuChan);
152 return;
153 }
154 else if(msg == "DELETE")
155 {
156 llOwnerSay("deleting resizer script...");
158 }
159 else
160 {
161 cur_scale += (float)msg;
162 }
163
164 //check that the scale doesn't go beyond the bounds
165 if(cur_scale > max_scale) { cur_scale = max_scale; }
166 if(cur_scale < min_scale) { cur_scale = min_scale; }
167
168 resizeObject(cur_scale);
169 }
170 }
171 }

Back to the Best Free Tools in Second Life and OpenSim.