Here is my newest teleport system....
IT WAS BROUGHT TO MY ATTENTION THAT THE LAST ONE DIDNT WORK... THERE WAS A COMPILER CHANGE. THIS ONE FIXES THAT AND ADDS A COUPLE OF FEATURES.
Its designed to read a notecard of locations in the following format:
Otherwhere Main Platform:<128,128,81>
Otherwhere Cafe:<128,216,96>
...
...
and so on...
Its probably limited to 12 entries as there is no code to extend to more dialog menus... As always this is code is contributed freely to the public domain and is "AS-IS" I am not resposnsible for any damage that it may do to your regions or avatars.
ENJOY!
----------------------------------------------------------------------------------------------------------------
//Hud for testing Gitfinger Hotspur 26/04/08
// when hud is touched it presents a dialog with choices
//
vector targetPos = <1,1,1>; //The x, y, z coordinates to teleport.
string fltText = "Please Touch for Menu";
integer CHANNEL = 42; // dialog channel
list MENU_MAIN = []; // the main menu
list MENU_DEST = [];
string gName = "Teleport List"; // name of a notecard in the object's inventory
integer gLine = 0; // current line number
key gQueryID; // id used to identify dataserver queries
string cardline;
integer gNoteLines;
integer noOfLines;
integer i;
key lineID;
reset_pad()
{
vector target;
target = (targetPos- llGetPos()) * (ZERO_ROTATION / llGetRot());
llSitTarget(target, ZERO_ROTATION);
llSetSitText("Teleport");
llSetText(fltText, <1,1,1>, 1);
}
default {
state_entry()
{
// gLine = 1;
//gName = llGetInventoryName(INVENTORY_NOTECARD, 0); // select the first notecard in the object's inventor
//gQueryID = (key)llGetNumberOfNotecardLines(gName);
gNoteLines = llGetNumberOfNotecardLines(gName);
//integer noOfLines = (integer)llGetNotecardLine(gName,1);
llSay(0,"Loading " + (string)gNoteLines + " entries." );
for(i = 1; i <= gNoteLines; i++)
{
cardline = llGetNotecardLine(gName, i);
// string test = llGetNotecardLine(gName,1);
// llSay(0, test);
integer p = llSubStringIndex(cardline,"|");
integer s = llStringLength(cardline);
string place = llGetSubString(cardline, 0, (p-1));
string dest = llGetSubString(cardline, p+1, s);
list place2 = llParseString2List(place,[","],[]);
list dest2 = llParseString2List(dest,[" "],[]);
MENU_MAIN = llListInsertList(MENU_MAIN, place2, 1);
MENU_DEST = llListInsertList(MENU_DEST, dest2, 1);
llSay(0, place+":"+dest);
}
llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users)
reset_pad();
}
dataserver(key queryid, string data)
{
if (queryid == gQueryID)
{
noOfLines = (integer)data;
llSay (0,(string)noOfLines);
}
if (queryid == lineID)
{
cardline = data;
}
}
on_rez(integer startup_param)
{
reset_pad();
}
changed(integer change)
{
if (change & 0x20)
{
llSleep(0.15);
llUnSit(llAvatarOnSitTarget());
}
}
touch_start(integer total_number)
{
llDialog(llDetectedKey(0), "Where do you want to go?", MENU_MAIN, CHANNEL); // present dialog on click
}
listen(integer channel, string name, key id, string message)
{
// string response_string;
list message2 = llParseString2List(message,[","],[]);
integer menuindex = llListFindList( MENU_MAIN, message2 );
integer menuindex2 = llListFindList( MENU_DEST, message2 );
if (menuindex != -1) // verify dialog choice
{
string response_string = " You picked the option '" + message + "'.";
vector targetPos = llList2Vector(MENU_DEST,menuindex);
string targetString = llList2String(MENU_DEST,menuindex);
fltText = "Teleport set for: " + message + " @ Position: " + targetString;
vector target = (targetPos- llGetPos()) * (ZERO_ROTATION / llGetRot());
llSitTarget(target, ZERO_ROTATION);
llSetSitText("Teleport");
llSetText(fltText, <1,1,1>, 1);
}
else
{
string response_string = (string)menuindex + ":" + name + " picked invalid option '" + llToLower(message) + "'.\n";
response_string = response_string + "Click HUD for dialog of options";
llSetText(response_string, <1,0,0>, 1.0);
}
// Set text to display in bright red
}
}