Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////////////////////////
- //
- // Gateway Script
- //
- // made for the =BB= Stellar Gateway Class for Builders Brewery
- // by Wolf Song (wolfslied)
- //
- // please do not give away with full permsissions
- // Set it to no modify/no transfer in your own builds
- //
- //////////////////////////////////////////////////
- ///////////////////////////
- // Global parameters
- ///////////////////////////
- string msg = "Where do you want to go?"; //text in dialog window
- // menu settings:
- string msgTimeout = "Sorry. Menu has timed out. Please try again.";
- float timeout= 20.0; //timeout for menu in seconds
- // name of the landmark notecard
- string notecardName = "Destinations";
- // lines on notecard should be in this format:
- // Land Name (appears in menu) = SLurl
- // Caution: Land names should not be longer than 12 characters or they won't be fully displayed
- /////////////////////////////////////////////////////
- // *** please ONLY change things below this line
- // if you know what you're doing ***
- // (or at least keep a backup copy of the script)
- /////////////////////////////////////////////////////
- string primName;
- integer channel;
- integer listenHandle;
- key id;
- integer diaChoice;
- integer diaMax = 9;
- string prevPG = "< Page ";
- string nextPG = "> Page ";
- integer pageNum;
- key ncID;
- integer notecardLine;
- list LandName;
- list destination_vector;
- vector dest;
- integer gAccessMode = 1; // Change who can use the teleporter: 1 - public, 2 - owner, 3 - group
- float gDelaySeconds = 1.0;
- /////////////////////////////////////
- // custom calls
- ////////////////////////////////////
- //debug
- say(string inputString)
- {
- llOwnerSay(inputString);
- }
- // open dialog
- openDialog(key ID, integer pageNum)
- {
- list buttons;
- integer firstChoice;
- integer lastChoice;
- integer prevPage;
- integer nextPage;
- string OnePage;
- diaChoice = llGetListLength(LandName);
- if (diaChoice <= 10) {
- buttons = LandName;
- OnePage = "Yes";
- }
- else {
- integer nPages = (diaChoice+diaMax-1)/diaMax;
- if (pageNum < 1 || pageNum > nPages) {
- pageNum = 1;
- }
- integer firstChoice = (pageNum-1)*diaMax;
- integer lastChoice = firstChoice+diaMax-1;
- if (lastChoice >= diaChoice) {
- lastChoice = diaChoice;
- }
- if (pageNum <= 1) {
- prevPage = nPages;
- nextPage = 2;
- }
- else if (pageNum >= nPages) {
- prevPage = nPages-1;
- nextPage = 1;
- }
- else {
- prevPage = pageNum-1;
- nextPage = pageNum+1;
- }
- buttons = llList2List(LandName, firstChoice, lastChoice);
- }
- list buttons01 = llList2List(buttons, 0, 2);
- list buttons02 = llList2List(buttons, 3, 5);
- list buttons03 = llList2List(buttons, 6, 8);
- list buttons04;
- if (OnePage == "Yes")
- {
- buttons04 = llList2List(buttons, 9, 11);
- }
- buttons = buttons04 + buttons03 + buttons02 + buttons01;
- if (OnePage == "Yes")
- {
- buttons = []+ buttons;
- }
- else
- {
- buttons =(buttons=[])+[prevPG+(string)prevPage, nextPG+(string)nextPage]+buttons;
- }
- llDialog(id, "Page "+(string)pageNum+"\n"+msg, buttons, channel);
- }
- //remove listener
- CancelListen()
- {
- llListenRemove(listenHandle);
- llSetTimerEvent(0);
- integer access_granted = FALSE;
- }
- default
- {
- on_rez(integer start_param)
- {
- llResetScript();
- }
- state_entry()
- {
- channel = (integer)llFrand(DEBUG_CHANNEL)*-1;
- primName = llGetLinkName(LINK_THIS);
- if (llGetInventoryKey(notecardName) == NULL_KEY)
- {
- llOwnerSay( "Notecard '" + notecardName + "' missing or unwritten.");
- return;
- }
- ncID = llGetNotecardLine(notecardName, notecardLine);
- llSitTarget(<0.0, 0.0, 0.51>, ZERO_ROTATION);
- llSetClickAction(CLICK_ACTION_SIT);
- }
- dataserver(key query_id, string data)
- {
- if (query_id == ncID)
- {
- if (data == EOF)
- say("Done reading notecard, found " + (string) notecardLine + " destinations.");
- else
- {
- list param = llParseString2List(data, ["="], []);
- string command = llStringTrim(llList2String(param, 0), STRING_TRIM);
- LandName +=command;
- string value = llStringTrim(llList2String(param, 1), STRING_TRIM);
- destination_vector += value;
- ++notecardLine;
- ncID = llGetNotecardLine(notecardName, notecardLine);
- }
- }
- }
- changed (integer change)
- {
- if (change & CHANGED_INVENTORY)
- llResetScript();
- if (change & CHANGED_LINK)
- {
- key USER = llAvatarOnSitTarget();
- integer access_granted = FALSE;
- if (gAccessMode == 1)
- {
- access_granted = TRUE;
- }
- else if (gAccessMode == 2)
- {
- if (USER == llGetOwner())
- {
- access_granted = TRUE;
- }
- }
- else if (gAccessMode == 3)
- {
- if (llSameGroup(USER))
- {
- access_granted = TRUE;
- }
- }
- else
- {
- llUnSit(USER);
- llSay(0," Sorry, you do not have permission to use this teleporter.");
- }
- if (access_granted)
- {
- id = USER;
- listenHandle = llListen( channel, "", id, "");
- llSetTimerEvent(timeout);
- pageNum = 1;
- openDialog(id, pageNum);
- }
- }
- }
- listen(integer channel, string name, key id, string choice)
- {
- if (choice == "-")
- {
- openDialog(id, pageNum);
- }
- else if (llSubStringIndex(choice, prevPG) == 0)
- {
- pageNum =(integer)llGetSubString(choice, llStringLength(prevPG), -1);
- openDialog(id, pageNum);
- }
- else if (llSubStringIndex(choice, nextPG) == 0)
- {
- pageNum =(integer)llGetSubString(choice, llStringLength(nextPG), -1);
- openDialog(id, pageNum);
- }
- else
- {
- integer i = llListFindList(LandName, [choice]);
- dest = (vector)llList2String(destination_vector, i);
- llRequestPermissions(id, PERMISSION_TELEPORT);
- CancelListen();
- }
- }
- run_time_permissions(integer perm)
- {
- if(PERMISSION_TELEPORT & perm)
- {
- vector _InitPos = llGetPos();
- llSetRegionPos(dest); // use llSetRegionPos function
- llSleep(gDelaySeconds); // Delay for llSetRegionPos bug and lag work-around.
- llUnSit(id);
- llSetRegionPos(_InitPos); // use llSetRegionPos function
- }
- }
- timer()
- {
- llSay(0, "The menu has timed out. Please try again.");
- CancelListen();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement