Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Scared of running out of prims to hold your scripts? Script controller may help.

Dom DaSilva
Registered User
Join date: 18 Jun 2005
Posts: 8
08-13-2006 02:49
I do not know if anyone has made something like this before but I thought it was a neat way to allow control of an object holding multiple scripts (instead of using up a main-land parcel's prim count by having single prims with single scripts).
Thanks to whoever (BlindWanderer?) wrote the LSL Wiki article code on llGetInventoryType for the InventoryType function.

Usage: On channel 0, general chat, type
"name of script in object" on/off

Function: Listens for the owner to say something following the syntax of the previous line. Uses llScriptReset and llScriptState to start/stop running the script "name of script in object" and run a default or cleanup script named at the beginning of the control script.

My current usage of the script:
To make a block of sand that's a part of parcel's whole 'beach/desert' theme go back and forth between being totally transparent and a phantom to being a solid part of the whole yard. Also, to make said block of sand tell me when scripting mentors are online.

Included are the control script and an idea of what a 'default' script could be.


Controller v09 13 2006 2 37 AM (next version will include access to a list of scripts within control script's control and a better method of listening):

CODE

string defaultscript = "Dummy";

string InventoryType(string name, integer type)
{
integer a = llGetInventoryType(name);
if(a == INVENTORY_NONE)
{
string b;
a = llGetInventoryNumber(type);
name = llToLower(name);
while(a)
if(llToLower(b = llGetInventoryName(type,--a)) == name)
return b;
}else if(a == type)
return name;
return "";
}

default
{
state_entry()
{
if (InventoryType(defaultscript, INVENTORY_SCRIPT)=="")
{defaultscript=""; llSay (0, "Default script set to nothing.");}

llListen (0, "", llGetOwner(), "");
}

listen (integer channel, string name, key id, string message)
{
if (id!=llGetOwner()) { return;}
string mes="";
mes=llToLower(message);
list parsedmessage=[];
string word1=""; string word2=""; string word3=""; string word4=""; string word5=""; string word6=""; string word7="";
string QuoteString="";

if (llSubStringIndex(message, "\"") != -1)
{
QuoteString = llGetSubString(message, llSubStringIndex(message, "\"") + 1, -1);
//QuoteString =
//llSay (0,(string) llSubStringIndex(QuoteString, "\""));
QuoteString = llGetSubString(QuoteString, 0, llSubStringIndex(QuoteString, "\"") - 1); //);
//llSay (0, );
}


parsedmessage = llParseString2List( llGetSubString(message, llStringLength(QuoteString) + 3, -1) , [" "], [""]);
word1 = llList2String (parsedmessage, 0);
// word2 = llList2String (parsedmessage, 1);
// word3 = llList2String (parsedmessage, 2);
// word4 = llList2String (parsedmessage, 3);
// word5 = llList2String (parsedmessage, 4);
// word6 = llList2String (parsedmessage, 5);
// word7 = llList2String (parsedmessage, 6);

integer scriptstatus;


if (word1=="off")
{
scriptstatus = FALSE;
if (defaultscript!="")
{
llResetOtherScript (defaultscript);
llSetScriptState (defaultscript, TRUE);
}
}
if (word1=="on") { scriptstatus = TRUE;}

if (InventoryType(QuoteString, INVENTORY_SCRIPT)=="")
{
llSay (0, "The script "+QuoteString+ " is not within my control."); return;
}

QuoteString=InventoryType(QuoteString, INVENTORY_SCRIPT);

if (QuoteString!="" && QuoteString!=llGetScriptName())
{
//llSay (0, (string)llStringLength(QuoteString));
llResetOtherScript (QuoteString);
llSetScriptState (QuoteString, scriptstatus);
llSay (0, "Just set the script "+QuoteString+ "'s status to " +word1+".");
}
}
}



Dummy script:
CODE

default
{
state_entry()
{
llSetText ("dummy text", <0,0,0>, 0);
}

}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
08-17-2006 18:02
/54/a1/130812/1.html
_____________________
i've got nothing. ;)