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 Self_Upgrading_Script  

Self_Upgrading_Script

Self Upgrading Script by Cron Stardust.lsl

Category: Upgrade script
By : Cron Stardust
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Self_Upgrading_Script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Self_Upgrading_Script_by_Cron_Stard_1.lsl
1
2 //********************************************************
3 //This Script was pulled out for you by YadNi Monde from the LSL WIKI at http://wiki.secondlife.com/wiki/LSL_Library, it is intended to stay FREE by it s author(s) and all the comments here in ORANGE must NOT be deleted. They include notes on how to use it and no help will be provided either by YadNi Monde or it s Author(s). IF YOU DO NOT AGREE WITH THIS JUST DONT USE!!!
4 //********************************************************
5
6
7
8
9
10 //Thanks to Markov Brodsky's Self Upgrading Script and Jippen Faddoul's update to the idea, I was inspired to add to the flexibility and usefulness of their original works.
11 //
12 //Markov Brodsky's original code is quite good, and I based my own implementation upon it, but it has an admitted flaw: It requires that all the scripts that use it have no spaces within the name. For me this will not do. I like my space ;D
13 //
14 //Jippen Faddoul's update is also pretty good, but while it is nicely shortened and optimized, it can't handle being copied into the prim more than 2 times. This makes it unusable for my coding style. (Tweak, save, copy, test, repeat...)
15 //
16 //So here's my edition to fix those shortcomings. (You may use this code freely and distribute it freely, but DO NOT even try to SELL it.)
17 //As far as my testing was able to show, I was able to have spaces in my script names and I was even able to tack on a number at the end of my script for personal version tracking and had no troubles. I was able to copy the script into the same prim over and over again with only the latest ever staying.
18 //
19 //Cron
20 //
21 //Note: Due to the nature of SL, your script's name will alternate between "scriptname" and "scriptname 1", where "scriptname" is the actual name of your script.
22
23
24
25
26
27 // Self Upgrading Script by Cron Stardust based upon work by Markov Brodsky and Jippen Faddoul. If this code is used, this header line MUST be kept.
28 upgrade() {
29 //Get the name of the script
30 string self = llGetScriptName();
31
32 string basename = self;
33
34 // If there is a space in the name, find out if it's a copy number and correct the basename.
35 if(llSubStringIndex(self, " ") >= 0) {
36 // Get the section of the string that would match this RegEx: /[ ][0-9]+$/
37 integer start = 2; // If there IS a version tail it will have a minimum of 2 characters.
38 string tail = llGetSubString(self, llStringLength(self) - start, -1);
39 while(llGetSubString(tail, 0, 0) != " ") {
40 start++;
41 tail = llGetSubString(self, llStringLength(self) - start, -1);
42 }
43
44 // If the tail is a positive, non-zero number then it's a version code to be removed from the basename.
45 if((integer)tail > 0) {
46 basename = llGetSubString(self, 0, -llStringLength(tail) - 1);
47 }
48 }
49
50 // Remove all other like named scripts.
52 while(n-- > 0) {
54
55 // Remove scripts with same name (except myself, of course)
56 if(item != self && 0 == llSubStringIndex(item, basename)) {
58 }
59 }
60 }
61
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
63 // * The real start of the universe.
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
65
66
67 default {
68 state_entry() {
69 upgrade();
70 }
71 }// END //

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