Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Utility - Copy/Paste/Delete Scripts

Alondria LeFay
Registered User
Join date: 2 May 2003
Posts: 725
04-03-2005 09:15
I create quite a few things with pre-existant modules of scripts. It grew to become a pain to manually drag certain scripts into new objects over and over so I created a set of utility scripts to automate this. Inorder to copy the scripts, drop UTIL.copyscripts into the object you want to copy the scripts from, and UTIL.pastescripts into the object you want them copied into. The utility scripts will transfer all the scripts and then remove themselves. I also include UTIL.deletescripts, which is a quick way to remove all scripts from an object.
Anyways, they are nothing too special, I just found myself using them a lot so I figured I'd pass them on.


UTIL.copyscript:
CODE

// UTIL.copyscripts.lsl
// By Alondria LeFay
// Version 1.0

integer lhook;
integer ch = 7983424;
integer pin = 75645;

alInit(integer argi)
{
if (lhook)
{
llListenRemove(lhook);
}
llListen(ch,"","","");
llSay(0,"Drop UTIL.pastescripts into object to copy scripts to.");
}

alParse(integer channel, string name, key id, string message)
{
list args;
args=llParseString2List(message, [" "],[]);
string obj=llList2String(args,0);
args=llDeleteSubList(args,0,0);
if (obj == "paste")
{
string foo = llList2String(args,0);
integer pw = llList2Integer(args,1);
llSay(0,"Transfering Scripts...");
integer num = llGetInventoryNumber(INVENTORY_SCRIPT);
integer i;
list scripts;
for (i = 0; i < num; i = i + 1)
{
string tmps = llGetInventoryName(INVENTORY_SCRIPT,i);
if (tmps != llGetScriptName())
{
llRemoteLoadScriptPin(foo,tmps,pin, llGetScriptState(tmps),0);
}
}
llSay(0,"Done!");
llRemoveInventory(llGetScriptName());
}
}

default
{
on_rez(integer argi)
{
alInit(argi);
}
state_entry()
{
alInit(0);
}
listen(integer channel, string name, key id, string message)
{
alParse(channel, name, id, message);
}
}



UTIL.pastescripts:
CODE

// OBJ.SLAmp.API
// By Alondria LeFay
// Version 1.0

integer lhook;
integer ch = 7983424;
integer pin = 75645;

alInit(integer argi)
{
if (lhook)
{
llListenRemove(lhook);
}
llSetRemoteScriptAccessPin(pin);
llSay(ch,"paste " + (string)llGetKey());
llRemoveInventory(llGetScriptName());
}

default
{
on_rez(integer argi)
{
alInit(argi);
}
state_entry()
{
alInit(0);
}
}


UTIL.deletescripts
CODE

// UTIL.deletescripts.lsl
// By Alondria LeFay
// Version 1.0

integer lhook;
list scripts;

alInit(integer argi)
{
if (lhook)
{
llListenRemove(lhook);
}
llSay(0,"Deleting scripts....");
integer num = llGetInventoryNumber(INVENTORY_SCRIPT);
integer i;
for (i = 0; i < num; i = i + 1)
{
string tmps = llGetInventoryName(INVENTORY_SCRIPT,i);
if (tmps != llGetScriptName())
{
scripts = scripts + [ tmps ];
}
}
for (i = 0; i < llGetListLength(scripts); i = i + 1)
{
llRemoveInventory(llList2String(scripts,i));
}
llSay(0,"Done!");
llRemoveInventory(llGetScriptName());
}

default
{
on_rez(integer argi)
{
alInit(argi);
}
state_entry()
{
alInit(0);
}
}
Caoimhe Armitage
Script Witch
Join date: 7 Sep 2004
Posts: 117
Original Thread:
04-16-2005 21:34
/15/81/41210/1.html
ne

Very cute idea and I'm starting to reach the level of complexity where I see the need (average of 3 scripts/object now and growing). Mind you, I cut&paste everything from CVS via Emacs rather than relying on SL's unversioned script storage, so I may never get to using these tools, but good idea nevertheless.

- C
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
04-25-2005 08:19
/54/ce/44189/1.html
_____________________
i've got nothing. ;)