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
Upgrade Script Auto_upgrader  

Auto_upgrader

Auto-upgrader-script-by-fred-huffhines.lsl

Category: Upgrade Script
By : Fred Huffhines
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Auto_upgrader
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Autoupgraderscriptbyfredhuffhines_1.lsl
1
2
3
4
5 //////////////
6 // auto-upgrader, by fred huffhines, distributed under GPL license.
7 // partly based on the self-upgrading scripts from markov brodsky and jippen fadoul.
8 // the function auto_upgrade() should be added to a version numbered script that you wish
9 // to give the capability of self-upgrading. see example invocation at end of file.
10 // this script supports a notation for versions where a 'v' character and a number in the
11 // form "major.minor" reside at the end of script names, e.g. "grunkle script by ted v8.2".
12 // when the script is dropped into an object with a different version, the most recent
13 // version eats any existing one.
14
15 integer posn;
16
17 auto_upgrade()
18 {
19 string self = llGetScriptName(); // the name of this script.
20 string basename = self; // script name with no version attached.
21
22 if(llSubStringIndex(self, " ") >= 0)
23 {
24
25 // minimum script name is 2 characters plus version.
26 for (posn = llStringLength(self) - 1; (posn >= 2) && (llGetSubString(self, posn, posn) != " "); posn--)
27 {
28 // find the space.
29 }
30
31 if(posn < 2) return; // no space found.
32 string suffix = llGetSubString(self, posn, -1);
33 // ditch the space character for our numerical check.
34 string chopped_suffix = llGetSubString(suffix, 1, llStringLength(suffix) - 1);
35 // strip out a 'v' if there is one.
36 if(llGetSubString(chopped_suffix, 0, 0) == "v")
37 chopped_suffix = llGetSubString(chopped_suffix, 1, llStringLength(chopped_suffix) - 1);
38 // if it's a valid floating point number and is greater than zero, that works for our version.
39 if((float)chopped_suffix > 0.0)
40 basename = llGetSubString(self, 0, -llStringLength(suffix) - 1);
41 }
42
43 // find any scripts that match the basename. they are variants of this script.
44 for (posn = llGetInventoryNumber(INVENTORY_SCRIPT) - 1; posn >= 0; posn--)
45 {
46 string curr_script = llGetInventoryName(INVENTORY_SCRIPT, posn);
47 // remove scripts with same name (except myself, of course).
48 if( (curr_script != self) && (llSubStringIndex(curr_script, basename) == 0) )
49 {
50 llRemoveInventory(curr_script);
51 }
52 }
53 }
54 //////////////
55
56 // example usage of the upgrader:
57 default
58 {
60 {
61 auto_upgrade();
62 }
63 } // end

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