Commands::
"/55 id" :: all prims running this script will respond with there name and number of prims saved
"/55 <name> save" :: saves the keys for each Prim in the linkset
"/55 <name> restore" :: puts the "saved" links back together in order(will have to run this command twice is scripted prim is not attached to other prims.)
CODE
list linkedkeys = []; //this is the list of keys in link order including this prim
string setname = "mod2";// this is the sub object answers too
restorealllinks()
{
integer x = 1;
llBreakAllLinks();
for(x = 0; x < llGetListLength(linkedkeys);x++)
{
llCreateLink(llList2Key(linkedkeys, -x), TRUE);
llOwnerSay( (string)(x+1) + "added so far");
}
}
savealllinks()
{
linkedkeys = [];
integer x = 0;
if (llGetNumberOfPrims() == 1)
{
llOwnerSay("Attach me to something first");
return;
}
for (x = 1; x <= llGetNumberOfPrims(); x++)
{
//llOwnerSay((string)llGetLinkKey(x));
llOwnerSay((string)x + " saved");
linkedkeys += llGetLinkKey(x);
llOwnerSay((string)llList2Key(linkedkeys, x - 1));
}
}
default
{
state_entry()
{
// get permission to change links for objects owned by AV.
llRequestPermissions(llGetOwner(),PERMISSION_CHANGE_LINKS);
llListen(55,"",llGetOwner(),"");
}
listen(integer channel, string name, key id, string message)
{
list pmessage = llParseString2List(message, [" "],[]);
llOwnerSay(name);
if (llList2String(pmessage,0) == "id") llOwnerSay(setname + ":" + (string)llGetListLength(linkedkeys) + "prims.");
if (llList2String(pmessage,0) == setname)
{
llOwnerSay( "Thats me boss");
if (llList2String(pmessage,1) == "save") savealllinks();
if (llList2String(pmessage,1) == "restore") restorealllinks();
}
}
}