Change font size
It is currently Mon Nov 19, 2018 10:17 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 5 posts ]
Author Message
 Post subject: Injector Script. Inject Items etc into Linkset Pims
PostPosted: Mon Jan 04, 2010 9:45 pm 
OSG Elite
User avatar

Joined: Wed Mar 11, 2009 3:57 pm
Posts: 444
Hi There Folks...

I coded this up due to a request in another posting here and figured I should put it into it's own posting.

What this does ?
Well simply put, it will take an item that is in the root prim of a linkset and "Inject" it into all the child Prims in that Linkset. This can be a Script, Notecard, Object, pretty much anything you want. It can only push ONE Item to a prim. There are better and more efficient methods to do this, but Sadly, in OpenSim as of this date, the inventory systems and LSL via the current XEngine has it's limits, so this is done in a more Roundabout way to get the job done. The result is that this system is a bit slow as it will only inject 5 prims at a time in 10 seconds... This is done to allow the inventory in the prims to be comitted by the asset servers and to not have the script choke while waiting.

It is a little chatty as it tells you what it's doing and it is only accessible by the owner. The details are all outlined in the Script Header. I've tested this with Notecards, Objects and Scripts and it works, even without the finesse that it should have.

Have Fun and hope it's useful for folks in General.

{L_CODE}:
// ===========================================================================================
// Script Title:     Injector Script 1.0
// Created by:       WhiteStar Magic
// Creation Date:    January 04, 2010
// Platforms:
//    OpenSim:       Tested and Operational on Version: OpenSim 0.6.9 (Dev) 9c4e6f0-r11855 (interface version 6)
//
// Revision:        1.0
// Revision History:
//  based on my earlier works in SL
//
// Conditions:
// Please maintain this header. If you modify the script indicate your
// revision details / enhancements
//
// Support: If needed and as Time Permits
//
// Licensing:  Creative Commons 2.5 (Canada) OpenSource
//
// http://creativecommons.org/licenses/by/2.5/ca/
// http://creativecommons.org/licenses/by/2.5/ca/legalcode.en
// ================================================================
// ** SCRIPT NOTES **
//
// Injects the Specified Inventory Item into ALL Prims within a LinkSet
// IF Script see Variable Notes below
//      Once Completed, you will have to Select the LinkSet and set Script to RUNNING to initialize
//      You will have to take the LinkSet into Inventory and re-rez it for Scripts to activate
//      !! THIS IS A SAFETY PRECAUTION  DO NOT CHANGE !!
//  IF not Script, Items will be deployed and available within the Prims
//  AutoClean Option to delete Injector Script from Root Prim
//
// ** SPECIAL NOTES **
//  Due to the delayed nature of of Inventory Commits, this system uses a stepping timer to complete the task
//  It injects 5 items and cycles and the timer will kick to inject the next 5 items.
//  This is a Throttling to prevent the Script Engine from choking on the commit delay
//  There IS more efficient ways to accomplish this, but as of this date, they cannot be employed in OpenSim
//  The result, is that this is a slow process and can take 10 seconds per 5 prims.  Large LinkSets will take time.
//
//================================================================
// === USER VARIABLES to Change ===
//
string  InjectionFile   = "ReadMe.txt"; // Put the Item Name here that you wish to Inject into the Prims
integer InjectScript    = FALSE;        // Set to FALSE if injecting something OTHER THAN SCRIPT    Set to TRUE for Scripts
integer InjectActive    = TRUE;         // SET to FALSE to send script to Prim as Inactive (FOR SCRIPTS ONLY)
integer AutoClean       = FALSE;        // IF set to TRUE it will delete THIS script when done injecting
//
// ==================//
// DO NOT EDIT BELOW //
// ==================//
integer num;
integer processed = -1;
integer i;
list LSTprims;
integer PrimCount;
//
// Functions
Completed()
{
    llSetText("", <1,1,1>, 1);
    llOwnerSay("\nInjection Completed.  Prims Processed: [ "+(string)processed+" of "+(string)num+" ]"+
        "\n[IF Scripts Injected ] NEXT:  Take & Rez this object and then go to 'Tools' -> 'Set Scripts to Running in Selection', and then Re-Rez this object again.");
    if(AutoClean) llRemoveInventory(llGetScriptName());
}
//
// Main Application
default
{
    state_entry()
    {
        if(llGetInventoryType(InjectionFile) != -1)
        {
            llOwnerSay("\nLinked Prim Injector Running\nthe '"+InjectionFile+"' is in the root prim with this script");
            llSetText("Touch Prim to Start Injection Process", <1,1,1>, 1);
        }
        else llOwnerSay("Place the "+InjectionFile+" script in me.");
    }
   
    touch_start(integer num_detected)
    {
        if (llDetectedKey(0)==llGetOwner())
        {
            if (llGetInventoryType(InjectionFile) != -1)
            {
                num = llGetNumberOfPrims();
                llOwnerSay("Deploying "+InjectionFile+" to "+(string)num+" Prims... Please wait. This may take some time.");
                integer i = 1;
                while (i <= num)
                {
                    LSTprims += llGetLinkKey(i);
                    i++;
                }
                if(InjectScript) llSetScriptState(InjectionFile, InjectActive); // IF Script, SETS Script to Running or NOT
                PrimCount = llGetListLength(LSTprims);
                llSetTimerEvent(10.0);
            }
            else llOwnerSay("Place the "+InjectionFile+" in me.");
        }
        else llSay(0, "This is Owner Only Restricted");
    }
   
    timer()
    {
        i = -1;
        while (i <= 5)
        {
            key primkey;
            if((PrimCount >= 0) && (processed <= num))
            {
                primkey = llList2Key(LSTprims,(processed+1));
                if(primkey !="")
                {
                    // If this Prim's Key is Primkey do NOT give to self
                    if(llGetKey() != primkey) llGiveInventory(primkey, InjectionFile);
                }
            }
            else return;
            ++i;
            ++processed;
            if(primkey !="")
            {
                llOwnerSay("Processing Prim #: ["+(string)processed+"] UUID: "+(string)primkey);
                float Percentile = (((float)processed*100.0)/((float)num));
                string Percent = llGetSubString((string)Percentile,0,llSubStringIndex((string)Percentile,"."));
                llSetText(Percent + " % Completed.\nPrim # "+(string)processed+" of "+(string)num, <1,1,1>, 1);
            }
            if(processed == num)
            {
                llSetTimerEvent(0.0);
                Completed();
            }
        }
    }
}


_________________
No further support of any kind, for any of my materials. Use as/is whereis.
PLEASE UNSTICKY Any Stickied Posting by myself.


Top
 Profile  
 
 Post subject: Re: Injector Script. Inject Items etc into Linkset Pims
PostPosted: Tue Jan 05, 2010 5:47 pm 

Joined: Fri Dec 25, 2009 12:15 pm
Posts: 41
Works like a Champ! Awesome script, thank you very much Whitestar.

:D


Top
 Profile  
 
 Post subject: Re: Injector Script. Inject Items etc into Linkset Pims
PostPosted: Tue Jan 05, 2010 6:18 pm 
OSG Elite
User avatar

Joined: Wed Mar 11, 2009 3:57 pm
Posts: 444
Glad it serves your needs...

Hopefully it will help others too. Can come in very handy all around. Especially if injecting other things into prims. Hopefully people will realize the potential this can do.

_________________
No further support of any kind, for any of my materials. Use as/is whereis.
PLEASE UNSTICKY Any Stickied Posting by myself.


Top
 Profile  
 
 Post subject: Re: Injector Script. Inject Items etc into Linkset Pims
PostPosted: Fri Oct 08, 2010 11:32 am 
OSG Elite
User avatar

Joined: Thu Dec 11, 2008 7:51 am
Posts: 392
Location: England UK
Ecellent script WS! Never needed it until now, and its working a treat!

Thank you :)

_________________
"Nothing lasts forever; It's scientific"
~David Byrne (Talking Heads)


Top
 Profile  
 
 Post subject: Re: Injector Script. Inject Items etc into Linkset Pims
PostPosted: Sun Feb 20, 2011 9:51 am 
Furious Typer
User avatar

Joined: Fri Jul 16, 2010 2:53 pm
Posts: 240
This is just awesome!!

I made a mistake with seting up a texture in some 200 prims. I used your Injector Script to send a texture aligner script to all those prims. It worked great.

Thank you :)

Selea


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 5 posts ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net