Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need help limiting a list to one set of elements

Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
09-29-2006 10:56
Well I am still proud of myself because this was working fine(pat's self on back. and says "not bad for a scripting noobie";). But now I am greedy to learn more and expand the capabilites of this script. I want to be able to redefine the llDIalog menu according to the sim I am in but have been scratching my head all morning trying to figure out how to start. Any help would be appreciated on where to start.

Ooops editted to say: The list has 3 elements in like this example:
Home(user defined),<0.0, 0.0, 0.0>,Sesia(region name)

CODE

//Menu Driven Teleport HUD by Jesse Barnett
//Changed to Meun driven with region specific menus
//A significant thanks to Teneo Hopes wonderful Teleport Script


list menu_dest=["Options"];//Leave this alone
list dest;//List of Destinations in memory
list menu_options=["Add", "Remove", "Back", "List"]; //menu options
integer chan;
integer freemem;
string sim;
string object = "pumpkin"; // Name of object to rez
default
{
state_entry()
{
llListenRemove(chan);
}

touch_start(integer num_detected)
{
chan = 9;//change to a better - channel
sim = llGetRegionName();//Use this to limit menu to local destinations
llListen(chan,"",llGetOwner(),"");
llSetTimerEvent(20);
/////Need to change this so that menu_dest only lists dest with this sim name
llDialog(llDetectedKey(0), "Choose destination in " + sim + " or Options to add/remove destinations", menu_dest, chan);
}

listen(integer channel, string lm, key id, string message)
{
list params = llParseString2List(message,[" "],[]);
if (llListFindList(menu_dest + menu_options, [message]) != -1)
{
if (message == "Options")
{
llDialog(id, "Pick an option!", menu_options, chan);
}

else if (message == "Back")
{
llDialog(id, "Where in this sim do you want to go?", menu_dest, chan);
}

else if (message == "Add")
{
freemem = (llGetFreeMemory());
if (freemem < 200)//Limit list length to available memory
//Orginally had this limited to only 11 destinations
//But I want MORE!!!!
{
llOwnerSay("You can not add any more destinations");
}
else
{
llOwnerSay("What do you want to name this destination?");
state adddest;
}
}

else if (message == "Remove")
{
llDialog(id, "Which desination do you want to remove?", menu_dest, chan);
state remdest;
}

else if (message == "List")
{
integer i;
if(llGetListLength(dest) > 0)
{
for (i = 0; i < llGetListLength(dest); i+=3)
{
string places = llList2String(dest, i);
string loc= llList2String(dest, i+1);
string sim = llList2String(dest, i+2);
llOwnerSay(places + " = " + loc + ", " + sim);
}
}
else
{
llOwnerSay("No Destinations Available.");
return;
}
}
else if(llListFindList(dest,[message]) != -1)
{
integer index = llListFindList(dest, [llList2String(params,0)]);
if(index != -1)
{
vector target = (vector)llList2String(dest, index+1);
integer chanfran = (integer)llFrand(9999999 - 9000000) + 9000000;
vector pos = llGetPos();
llSay(0,"Touch the pumpkin to take a ride");
llRezObject(object, (pos + llRot2Fwd(llGetRot()) + <1.2,1.2,0>), ZERO_VECTOR, ZERO_ROTATION, chanfran);
llWhisper(chanfran, (string)target);
return;
}
}
}
}
timer()
{
llSetTimerEvent( 0 );
llListenRemove(chan);
return;
}
}
state adddest
{
state_entry()
{
chan = 0;
llSetTimerEvent(20);
llListen(chan,"",llGetOwner(),"");
}
listen(integer chan, string name, key id, string newdest)
{
vector pos = llGetPos();
sim = llGetRegionName();
dest = dest + [newdest, pos, sim];
menu_dest = menu_dest + [newdest];
//Will remove this after I have menu_dest working with sim names
//Will also have to limit to only 11 destinations per sim
llOwnerSay("Added : " + newdest + " = " + (string)pos + ", " + (string)sim);
state default;
}
timer()
{
llListenRemove(chan);
llOwnerSay("Timeout. Click TP HUD to start again");
state default;
}
}

state remdest
{
state_entry()
{

chan = 9;
llSetTimerEvent(20);
llListen(chan,"",llGetOwner(),"");
}
listen(integer chan, string name, key id, string remdest)
{
integer d = llListFindList(dest, [remdest]);
integer e = llListFindList(menu_dest, [remdest]);
//Will remove this after I have menu_dest working with sim names
if(d != -1)
{
dest = llDeleteSubList(dest, d, d + 2);
menu_dest = llDeleteSubList(menu_dest, e, e + 0);
//Will remove this after I have menu_dest working with sim names
llOwnerSay("Removed : " + remdest);
state default;
}
}
timer()
{
llListenRemove(chan);
llOwnerSay("Timeout. Click TP HUD to start again");
state default;
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
09-29-2006 13:51
Okay while digging through the Wiki I came across strided lists and I incorporated that into the script for getting the button names. (The Script above is not edited to show that)

So that changes the question somewhat. How can I filter this statement:

main_menu = llList2ListStrided(dest, 0, -1, 3);

to show only the names of the destinations for the sim I am in?
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum