Teleport Board - Single Destination
Revision as of 23:30, 9 August 2020 by Admindiamond (talk | contribs)
When a user clicks the prim they will get a menu offering to tp them or give information about the place. The information option will deliver all prim contents other than the script and the location note card. It will work inside the same sim, going to another sim or even another hypergrid destination
This script is written in OLSL and will not compile in second life but works in Opensim under both the X and Y Engine.
- Create a prim in world
- Add a new script to the prim
- Copy-paste the licence and script
- Make a new notecard called Location and add it to the prims contents
- Adjust the notecard to your requirements
- Edit the two lists in the User Variables to change the fixed and dynamic button names
Contents
Licence
1 BSD 3-Clause License
2 Copyright (c) 2020, Sara Payne
3 All rights reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 2. Redistributions in binary form must reproduce the above copyright notice,
8 this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
11 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
12 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
13 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
14 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
15 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
16 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
17 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
18 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
19 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Script
1 vector landing;
2 vector lookAt;
3 string gridUri;
4 string regionName;
5 string destination;
6
7 integer mainMenuChannel; //global integer for menu channel
8 integer mainMenuChannelListen;//clobal control integer for turning menu listen on and off
9
10 SetUpListeners()
11 {//sets the coms channel and the random menu channel then turns the listeners on.
12 mainMenuChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0); //generates random main menu channel
13 mainMenuChannelListen = llListen(mainMenuChannel, "", NULL_KEY, "");//sets up main menu listen integer
14 llListenControl (mainMenuChannelListen, FALSE); //turns off listeners for main menu channel
15 }//close set up listeners
16
17 string CleanUpString(string inputString)
18 {
19 string cleanString = llStringTrim( llToLower(inputString), STRING_TRIM );
20 return cleanString;
21 }
22
23 ReadConfigCards(string notecardName)
24 { //Reads the named config card if it exists
25 if (llGetInventoryType(notecardName) == INVENTORY_NOTECARD)
26 { //only come here if the name notecard actually exists, otherwise give the user an error
27 integer notecardLength = osGetNumberOfNotecardLines(notecardName); //gets the length of the notecard
28 integer index; //defines the index for the next line
29 for (index = 0; index < notecardLength; ++index)
30 { //loops through the notecard line by line
31 string currentLine = osGetNotecardLine(notecardName,index); //contents of the current line exactly as it is in the notecard
32 string firstChar = llGetSubString(currentLine, 0,0); //gets the first character of this line
33 integer equalsIndex = llSubStringIndex(currentLine, "="); //gets the position of hte equals sign on this line if it exists
34 if (currentLine != "" && firstChar != "#" && equalsIndex != -1 )
35 { //only come here if the line has content, it does not start with # and it contains an equal sign
36 string instruction = llGetSubString (currentLine, 0, equalsIndex-1); //everything before the equals sign
37 string data = llGetSubString(currentLine, equalsIndex+1, -1); //everything after the equals sign
38 instruction = CleanUpString (instruction); //sends the instruvtion to the cleanup method to remove white space and turn to lower case
39 data = CleanUpString (data); //sends the data to the cleanup method to remove white space and turn to lower case
40 ProcessInstructionLine(instruction, data); //sends the instruction and the data to the Process instruction method
41 }//close if the line is valid
42 else
43 {
44 if ( (currentLine != "") && (firstChar != "#") && (equalsIndex == -1))
45 {
46 llOwnerSay("Line number: " + (string)index + " is malformed. It is not blank, and does not begin with a #, yet it contains no equals sign.");
47
48 }
49 }
50 }
51 }//close if the notecard exists
52 else
53 { //the named notecard does not exist, send an error to the user.
54 llOwnerSay ("The notecard called " + notecardName + " is missing, please address this");
55 }//close error the notecard does not exist
56 }//close read config card.
57
58 DeliverInfo(key aviUUID)
59 {
60 list inventoryItems;
61 integer inventoryNumber = llGetInventoryNumber(INVENTORY_ALL);
62 integer index;
63 for (index = 0; index < inventoryNumber; ++index )
64 {
65 string itemName = llGetInventoryName(INVENTORY_ALL, index);
66 if (itemName != llGetScriptName() && itemName != "Location")
67 {
68 if (llGetInventoryPermMask(itemName, MASK_OWNER) & PERM_COPY)
69 {
70 inventoryItems += itemName;
71 }
72 else
73 {
74 llSay(0, "Unable to copy the item named '" + itemName + "'.");
75 }
76 }
77 }
78 if (inventoryItems == [] ) llSay(0, "No copiable items found, sorry.");
79 else llGiveInventoryList(aviUUID, llGetObjectName(), inventoryItems); // 3.0 seconds delay
80 llResetScript();
81 }
82
83 ProcessInstructionLine(string instruction, string data)
84 {
85 if (instruction == "landing")
86 {
87 landing = (vector)data;
88 }
89 else if (instruction == "lookat")
90 {
91 lookAt = (vector)data;
92 }
93 else if (instruction == "griduri")
94 {
95 gridUri = (data);
96 }
97 else if (instruction == "regoin")
98 {
99 regionName = (data);
100 }
101 destination = gridUri + "/" + regionName;
102 }
103
104 Teleport(key aviUUID)
105 {
106 if (destination == "" || destination == "/")
107 {
108 llOwnerSay("Debug:Teleport: No Desination");
109 osTeleportAgent(aviUUID, landing, lookAt);
110 }
111 else
112 {
113 llOwnerSay("Debug:Teleport: Desitination Set");
114 osTeleportAgent(aviUUID, destination, landing, lookAt);
115 }
116 llRegionSayTo(aviUUID, 0, "Teleporting you to : " + destination);
117 }
118
119 default
120 {
121 changed (integer change)
122 {
123 if (change & (CHANGED_OWNER | CHANGED_INVENTORY | CHANGED_OWNER | CHANGED_REGION_START))
124 {
125 llResetScript();
126 }
127 }
128
129 on_rez(integer start_param)
130 {
131 llResetScript();
132 }
133
134 state_entry()
135 {
136 SetUpListeners();
137 ReadConfigCards("Location");
138 }
139
140 touch_start(integer count)
141 { //someones touched the prim
142 llListenControl (mainMenuChannelListen, TRUE);
143 list buttons = ["Teleport", "GetInfo"];
144 llDialog(llDetectedKey(0), "Please select from the following options", buttons, mainMenuChannel);
145 llSetTimerEvent(30);
146 }// close touch start
147
148 listen(integer channel, string name, key id, string message)
149 {//listens on the set channels, then depending on the heard channel sends the message for processing.
150 if (channel == mainMenuChannel)
151 {
152 llOwnerSay(message);
153 if (message == "Teleport") Teleport(id);
154 else if (message == "GetInfo") DeliverInfo(id);
155 }
156 }//close listen
157
158 timer()
159 {
160 llWhisper(PUBLIC_CHANNEL, "sorry the menu timed out, please click again");
161 llResetScript();
162 }
163
164 }// close state default
Notecard
1 #Location Config Card
2 #==============
3
4 # Blank lines are ignored
5 # Lines starting with a # are ingored
6
7 #To make a TP inside the same region leave the GRIDURI and Region blank
8 #Landing is the region position <x,y,z>
9 #LookAt is the direction <x,y,z> - this doesn't always work
10 #Grid Uri Examp;e: http://fireandicegrid.net:8002
11 #Region is the region name
12
13 Landing = <1,1,25>
14 LookAt = <0,0,0>
15 GRIDURI =
16 Region =
Syntax Highlighting
GeShi syntax highlighting is enabled on this wiki. <be>
When using the tabs described in the link, change the language part to "lsl". Eg.
syntaxhighlight lang="lsl" line
inside angled brackets <>