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 Theds_MegaPrim_Script_4  

Theds_MegaPrim_Script_4

This script allows you to resize the prim up to 64M per side, even if your SL client does not allow that yet. Menus or use chat commands. Examples: X = 5.5
Sets the X plane to 5.5 Y + .5
Adds .5 to the Y plane Z - 10
subtracts 10 from the Z plane xyz * .5
Reduces the prim by half xyz * 2
Doubles the size of the prim Set 20 15 .5
changes the prims X, Y and Z parameters to those numbers undo //will undo the last command

Category: Building
By : thedmanedman
Created: 2011-09-25 Edited: 2011-09-25
Worlds: Second Life

the Zip file

Download all files for Theds_MegaPrim_Script_4
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Theds_MegaPrim_Script_4_1.lsl
1 // Thed's Megaprim Sizer
2 // 20110914
3 // By Thedman Edman
4
5 ////////// ////////// //////////
6 //
7 // Version info:
8 // 0.1 Proof of concept release
9 // fully debugged
10 // 0.2 Comment and variable clean up for open release
11 // 0.3 Corrected Multiplier bug
12 // Help screen clean up
13 // 0.31 Changed variables in the size assign section
14 // 0.4 Added 'redo' to undo
15 // Sore code clean up
16 //
17
18 ////////// ////////// //////////
19 //
20 // Constants
21 //
22 key ThedKey = "46a9dc6e-9fed-46f4-8975-f5ca526ce6a4";
23 list Commands = ["X", "Y", "Z", "XYZ", "Undo", "Remove",
24 "=", "+", "-", "*",
25 "0", ".", "Go", "1", "2", "3", "4", "5", "6", "7", "8", "9" ];
26 string Err01 = "Invalid number of arguements";
27 string Err02 = "I could not understand the vector supplied";
28
29 ////////// ////////// //////////
30 //
31 // Global Variables
32 // available to all subroutines
33 //
34 integer MenuChannel=1222; // Is set random later to prevent crosstalk
35
36 key OwnerKey; // Holds owner's key
37 key ToucherKey; // Last one to touch it
38
39 integer Handle_0; //Menu listen
40 integer Handle_1; // Owner/ All Listen
41 integer Handle_2; // Thed Listen
42
43 vector UndoSize; //Holds size before change for undo function
44 string Command = ""; //Built from menu functions
45
46
47 ////////// ////////// //////////
48 //
49 // Routine to display help screen
50 //
51 DisplayHelp() {
52 llSay(0,"\nThank you for choosing a scripted product by Thed.\n This script allows you to resize the prim up to 64M per side, even if your SL client does not allow that yet. Click me to activate the menus or use chat commands\nExample commands:\n X = 5.5 // Sets the X plane to 5.5\n Y + .5 // Adds .5 to the Y plane\n Z - 10 // subtracts 10 from the Z plane\n xyz * .5 // Reduces the prim by half\n xyz * 2 // Doubles the size of the prim\n Set 20 15 .5 // changes the prims X, Y and Z parameters to those numbers\n undo //will undo the last command");
53 }
54
55
56 ////////// ////////// //////////
57 //
58 // Routine to set up Listen events
59 //
60 InitListen() {
61 Handle_0 = llListen(MenuChannel,"",NULL_KEY,""); //Listens to menu
62 Handle_1 = llListen(0,"",OwnerKey,""); //Listens to owner
63 Handle_2 = llListen(0,"",ThedKey,""); //Listens to Thed
64 }
65
66
67 ////////// ////////// //////////
68 //
69 // Routines to Display Menus
70 //
71 Display_Menu_Main(key Uid) {
72 Command=""; //Clear command
73 list Menu = llList2List( Commands, 0, 5);
74 llDialog(Uid, "Select from the options below" , Menu, MenuChannel);
75 }
76
77 Display_Menu_Functions(key Uid) {
78 list Menu = llList2List( Commands, 6, 9);
79 llDialog(Uid, "Select a function ... \n" + Command , Menu, MenuChannel);
80 }
81
82 Display_Menu_Num (key Uid) {
83 list Menu = llList2List( Commands, 10, -1);
84 llDialog(Uid, "Select an option ... \n" + Command , Menu, MenuChannel);
85 }
86
87
88 ////////// ////////// //////////
89 //
90 // Routine to remove this Script
91 //
92 KillScript() {
94 }
95
96
97 ////////// ////////// //////////
98 //
99 // Routine to display error
100 //
101 DisplayErr(string message) {
102 llInstantMessage(ToucherKey, message);
103 }
104
105
106 ////////// ////////// //////////
107 //
108 // Routine to process commands
109 //
110 ProcessCommands() {
111 Command=llToLower(Command);
112 list Words = llParseString2List( Command, [" "], []);
113 string Word1 = llList2String(Words,0);
114 string Word2 = llList2String(Words,1);
115 float F1 = llList2Float(Words,2);
116 vector CurSize=llGetScale();
118 //Note: May remove else commands to make it easier to follow
119 //Build +/-/= Vector in V1
120 if(Word1 == "x") V1 += <F1,0,0>;
121 if(Word1 == "y") V1 += <0,F1,0>;
122 if(Word1 == "z") V1 += <0,0,F1>;
123 if(Word1 == "xyz") V1 = <F1, F1, F1>;
124 //Now set V1 to the desired size based on function
125 if(Word2 == "+") V1 += CurSize;
126 if(Word2 == "-") V1 = CurSize - V1;
127 if(Word2 == "=") {
128 if(Word1 == "x") V1 = <F1,CurSize.y, CurSize.z>;
129 else if(Word1 == "y") V1 = <CurSize.x, F1, CurSize.z>;
130 else if(Word1 == "z") V1 = <CurSize.x, CurSize.y, F1>;
131 }
132 if(Word2 == "*") {
133 V1 = CurSize;
134 if(Word1 == "x" || Word1 == "xyz") V1.x *= F1;
135 if(Word1 == "y" || Word1 == "xyz") V1.y *= F1;
136 if(Word1 == "z" || Word1 == "xyz") V1.z *= F1;
137 }
138 //Set new prim size
139 ChangeSize(V1);
140 }// Process Commands
141
142
143 ////////// ////////// //////////
144 //
145 // Verify routines
146 //
147 integer VerifyCommand (string passed) {
148 //Check Current Word agianst menu for number items
149 return (llSubStringIndex( " xyzxyz", passed) >= 0 );
150 }
151
152 integer VerifyFunction (string passed) {
153 //Check Current Word agianst menu for number items
154 return (llSubStringIndex( " +-*=", passed) >= 0 );
155 }
156
157 integer VerifyNumbers (string passed) {
158 //Check Current Word agianst menu for number items
159 return (llSubStringIndex( " 0123456789.", passed) >= 0 );
160 }
161
162
163 ////////// ////////// //////////
164 //
165 // Routine to Change the size
166 // Also saves the undo size
167 //
168 ChangeSize(vector PassVec) {
169 UndoSize = llGetScale();
170 llSetScale(PassVec);
171 }
172
173
174 ////////// ////////// //////////
175 //
176 // Script Events start here
177 //
178 default {
179
180 changed(integer mask) { // something changed
181 //Triggered when the object containing this script changes owner.
182 if(mask & CHANGED_OWNER) {
184 }
185 }// End of Event Changed
186
187
188 on_rez (integer Start_Param) {
189 //Remove script if accidentally left inside of a prim
190 llSay(0,"Someone forgot to delete me, I'm outta here! Poof!");
191 KillScript();
192 }// End of Event State_entry
193
194
195 state_entry() {
196 OwnerKey = llGetOwner();
197 ToucherKey = OwnerKey;
198 UndoSize = llGetScale();
199 DisplayHelp();
200 //Randomize so it doesnt interfere with others
201 MenuChannel = -llFloor(llFrand(100000.0));
202 InitListen();
203 Display_Menu_Main(OwnerKey);
204 }// End of Event State_entry
205
206
207 touch_start(integer total_number) {
208 ToucherKey = llDetectedKey(0);
209 if(ToucherKey == OwnerKey || ToucherKey == ThedKey) {
210 Display_Menu_Main(ToucherKey);
211 }
212 }//End of Event touch_start
213
214
215 listen(integer FromMenu, string name, key id, string message) {
216 message=llToLower(message);
217 list Words = llParseString2List( message, [" "], []);
218 string Word1 = llList2String(Words,0);
219
220 //
221 // Chat Only commands:
222 //
223 if(!FromMenu) {
224 //Set
225 if(Word1 == "set") {
226 if(llGetListLength(Words) != 4) {
227 DisplayErr (Err01);
228 }
229 else ChangeSize(<llList2Float(Words,1),llList2Float(Words,2),llList2Float(Words,3)>);
230 }
231
232 // Verify real command other commands
233 if(VerifyCommand(Word1)) {
234 if(llGetListLength(Words) != 3) DisplayErr (Err01);
235 else {
236 Command = message;
237 ProcessCommands ();
238 }
239 }
240 }
241
242 //
243 // Menu driven command builder
244 //
245 if(FromMenu) {
246 //Add command to the command variable:
247 if(Word1 == "x" || Word1 == "y" || Word1 == "z"
248 || Word1 == "xyz") {
249 Command = Word1 + " ";
250 Display_Menu_Functions(ToucherKey);
251 }
252
253 //Add function to the command variable:
254 else if(Word1 == "+" || Word1 == "-" || Word1 == "*" || Word1 == "=") {
255 Command += Word1 + " ";
256 Display_Menu_Num(ToucherKey);
257 }
258 //Add Numbers to command variable:
259 //Check Current Word agianst menu for number items
260 else if(llSubStringIndex( "0123456789.", Word1) >= 0 ) {
261 Command += Word1;
262 Display_Menu_Num(ToucherKey);
263 }
264 //Go
265 else if(Word1 == "go") {
266 ProcessCommands();
267 Display_Menu_Main(ToucherKey);
268 }
269 }
270
271 //
272 // Menu or chat Commands
273 //
274
275 //Undo
276 if(Word1 == "undo") {
277 ChangeSize (UndoSize);
278 if(FromMenu) Display_Menu_Main(ToucherKey);
279 }
280
281 //Remove
282 else if(Word1 == "remove") {
283 KillScript();
284 }
285
286 }//End of Event Listen
287
288
289 }// default State

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