Don't click here unless you want to be banned.

LSL Wiki : LibrarySelfUpgradingScriptAlt

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl427.us.archive.org

Self Upgrading Script Alt


This is an alternative to the script created by MarkovBrodsky. Instead of having to physically update every child-prim, this will let you update the child-prims from a single source. You need to move a script to each child prim to begin with, but after that updating the child scripts is just a matter of calling a function.

NOTE: The SCRIPT_TO_UPDATE variable must name a script that exists in the inventory of the root prim.

1. Move the following script to each child-prim to begin with, or include the llSetRemoteScriptAccessPin(SCRIPT_PIN) call in the script to be updated and copy that script to each child-prim initially.

// Simple pin configuration for allowing other scripts 
    // to update the internal script 
    
   // Use an arbitrary PIN
   integer SCRIPT_PIN = 7589273495872;
    
   default {
      state_entry() {
         llSetRemoteScriptAccessPin(SCRIPT_PIN); 
      }
   }

2. Move the following script to the root prim. This script simply goes through each prim and updates the script.

// Simple update script to update the given script name 
   // to each of the child-prims in a linked set 
    
   integer SCRIPT_PIN = 7589273495872; 
   string SCRIPT_TO_UPDATE = "updated_script";
    
   UpdatePrims() {
      integer num_prims = llGetNumberOfPrims(); 
      integer i; 
      for (i = 2; i <= num_prims; i++) {
         key prim_key = llGetLinkKey (i); 
         llOwnerSay("Updating prim #" + (string)(i)); 
         llRemoteLoadScriptPin (prim_key, SCRIPT_TO_UPDATE, SCRIPT_PIN, TRUE, 0); 
      }
      llOwnerSay("Updated " + (string)(num_prims - 1) + " prims"); 
   }

   default {

      state_entry() { 
         llListen (9, "", llGetOwner(), "update"); 
      }

      listen(integer channel, string name, key id, string message)
      { 
         UpdatePrims(); 
      }

   }

3. Now, calling "/9 update" will update each prim in the link set. It's not going to be super-fast, because the llRemoteLoadScriptPin delays the script on each call, but it's a lot more convenient that having to drag updated scripts to each prim. You can delete the root prim script when you don't need it anymore.


Comments [Hide comments/form]
Added a missing semi-colon (;) for the second script.
-- SimonRaven (2006-12-11 04:37:32)
Attach a comment to this page: