Teleport Board - Single Destination
Revision as of 12:38, 17 January 2021 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
<be>
Contents
Script On Github
LSL And OSSL Script Library On GitHub
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 integer debug = TRUE;
7 integer mainMenuChannel;
8 integer mainMenuChannelListen;
9 key imageUUID;
10 string name;
11
12 SetUpListeners()
13 {//sets the coms channel and the random menu channel then turns the listeners on.
14 mainMenuChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0); //generates random main menu channel
15 mainMenuChannelListen = llListen(mainMenuChannel, "", NULL_KEY, "");//sets up main menu listen integer
16 llListenControl (mainMenuChannelListen, FALSE); //turns off listeners for main menu channel
17 }//close set up listeners
18
19 string locationTestString(string input)
20 {
21 string testValue = "TpLocation_";
22 string testString = llGetSubString(input, 0, llStringLength(testValue)-1);
23 string locationName = "";
24 if (testString == testValue)
25 {
26 list elements = llParseStringKeepNulls(input, "_", "!");
27 locationName = llList2String(elements, 1);
28 }
29 return locationName;
30 }
31
32 string CleanUpString(string inputString)
33 {
34 string cleanString = llStringTrim( llToLower(inputString), STRING_TRIM );
35 return cleanString;
36 }
37
38 ProcessInstructionLine(string instruction, string data)
39 {
40 if (instruction == "landing")
41 {
42 landing = (vector)data;
43 }
44 else if (instruction == "lookat")
45 {
46 lookAt = (vector)data;
47 }
48 else if (instruction == "griduri")
49 {
50 gridUri = data;
51 }
52 else if (instruction == "region")
53 {
54 regionName = data;
55 }
56 else if (instruction =="image")
57 {
58 imageUUID = data;
59 }
60 else if (instruction == "name")
61 {
62 name = data;
63 }
64 }
65
66 ReadConfigCards(string notecardName)
67 { //Reads the named config card if it exists
68 if (llGetInventoryType(notecardName) == INVENTORY_NOTECARD)
69 { //only come here if the name notecard actually exists, otherwise give the user an error
70 integer notecardLength = osGetNumberOfNotecardLines(notecardName); //gets the length of the notecard
71 integer index; //defines the index for the next line
72 for (index = 0; index < notecardLength; ++index)
73 { //loops through the notecard line by line
74 string currentLine = osGetNotecardLine(notecardName,index); //contents of the current line exactly as it is in the notecard
75 string firstChar = llGetSubString(currentLine, 0,0); //gets the first character of this line
76 integer equalsIndex = llSubStringIndex(currentLine, "="); //gets the position of hte equals sign on this line if it exists
77 if (currentLine != "" && firstChar != "#" && equalsIndex != -1 )
78 { //only come here if the line has content, it does not start with # and it contains an equal sign
79 string instruction = llGetSubString (currentLine, 0, equalsIndex-1); //everything before the equals sign
80 string data = llGetSubString(currentLine, equalsIndex+1, -1); //everything after the equals sign
81 instruction = CleanUpString (instruction); //sends the instruvtion to the cleanup method to remove white space and turn to lower case
82 data = CleanUpString (data); //sends the data to the cleanup method to remove white space and turn to lower case
83 ProcessInstructionLine(instruction, data); //sends the instruction and the data to the Process instruction method
84 }//close if the line is valid
85 else
86 {
87 if ( (currentLine != "") && (firstChar != "#") && (equalsIndex == -1))
88 {
89 llOwnerSay("Line number: " + (string)index + " is malformed. It is not blank, and does not begin with a #, yet it contains no equals sign.");
90
91 }
92 }
93 }
94 }//close if the notecard exists
95 else
96 { //the named notecard does not exist, send an error to the user.
97 llOwnerSay ("The notecard called " + notecardName + " is missing, please address this");
98 }//close error the notecard does not exist
99 }//close read config card.
100
101 Teleport(key aviUUID)
102 {
103 if (gridUri == "")
104 {
105 destination = regionName;
106 }
107 else
108 {
109 destination = gridUri + "/" + regionName;
110 }
111
112 if (destination == "" || destination == "/")
113 {
114 if (debug)
115 {
116 llOwnerSay("Debug:Teleport: No Desination, same region tp");
117 }
118 osTeleportAgent(aviUUID, landing, lookAt);
119 }
120 else
121 {
122 if (debug)
123 {
124 llOwnerSay("Debug:Teleport: Desitination Set as: " + destination);
125 }
126 osTeleportAgent(aviUUID, destination, landing, lookAt);
127 }
128 llRegionSayTo(aviUUID, 0, "Teleporting you to" + name);
129 }
130
131 string SetLocationName()
132 {
133 string locationName = "";
134 if (name == "")
135 {
136 if (regionName == "")
137 {
138 locationName += llGetRegionName();
139 }
140 else
141 {
142 locationName += regionName;
143 }
144 if (gridUri == "")
145 {
146 locationName += "@" + osGetGridName();
147 }
148 else
149 {
150 locationName += gridUri;
151 }
152 }
153 return locationName;
154 }
155
156 DeliverInfo(key aviUUID)
157 {
158 list inventoryItems =[];
159 integer inventoryNumber = llGetInventoryNumber(INVENTORY_ALL);
160 integer index;
161 for (index = 0; index < inventoryNumber; ++index )
162 {
163 string itemName = llGetInventoryName(INVENTORY_ALL, index);
164 if (debug)
165 {
166 llOwnerSay("Debug:DeliverInfo:ItemName: " + itemName);
167 }
168
169 if (!(itemName == llGetScriptName() || itemName == "TpLocation"))
170 {
171 if (debug)
172 {
173 llOwnerSay("Debug:DevliverInfo:" + itemName + "added to deliverables");
174 }
175 if (llGetInventoryPermMask(itemName, MASK_OWNER) & PERM_COPY)
176 {
177 inventoryItems += itemName;
178 }
179 else
180 {
181 llSay(0, "Unable to copy the item named '" + itemName + "'.");
182 }
183 }
184 }
185 if (inventoryItems == [] )
186 {
187 llRegionSayTo(aviUUID, PUBLIC_CHANNEL, "No copiable items found, sorry.");
188 }
189 else llGiveInventoryList(aviUUID, llGetObjectName(), inventoryItems); // 3.0 seconds delay
190 llResetScript();
191 }
192
193 UpdateImage()
194 {
195 llSetLinkPrimitiveParamsFast(ALL_SIDES, [PRIM_TEXTURE, ALL_SIDES, imageUUID, <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0]);
196 }
197
198 ProcessMenuChoices(key aviUUID, string message)
199 {
200 if (message == "Teleport")
201 {
202 Teleport(aviUUID);
203 }
204 else if (message == "GetInfo")
205 {
206 DeliverInfo(aviUUID);
207 }
208 }
209
210 default
211 {
212 on_rez(integer start_param)
213 {
214 llResetScript();
215 }
216 changed(integer change) // something changed, take action
217 {
218 if(change & CHANGED_OWNER | CHANGED_REGION_RESTART | CHANGED_INVENTORY)
219 {
220 llResetScript();
221 }
222 }
223
224 state_entry()
225 {
226 SetUpListeners();
227 ReadConfigCards("TpLocation");
228 llSetObjectName(SetLocationName() + " Teleport Board");
229 }
230
231 touch_start(integer num_detected)
232 {
233 llListenControl (mainMenuChannelListen, TRUE);
234 list buttons = ["Teleport", "GetInfo"];
235 llDialog(llDetectedKey(0), "Please select from the following options", buttons, mainMenuChannel);
236 llSetTimerEvent(30);
237 }
238
239 listen(integer channel, string name, key uuid, string message)
240 {//listens on the set channels, then depending on the heard channel sends the message for processing.
241 if (channel == mainMenuChannel)
242 {
243 ProcessMenuChoices(uuid, message);
244 }
245 }//close listen
246
247 timer()
248 {
249 llWhisper(PUBLIC_CHANNEL, "sorry the menu timed out, please click again");
250 llResetScript();
251 }
252 }
Notecard (notecard name must me TpLocation)
1 #Fire And Ice Teleport Board - Single Location
2 #==============================
3
4 #Will work on the same sim / to another sim on the same grid or a location on another grid.
5 #All locations needs a landing point and looking at
6
7 #Teleport In the same region:
8 #----------------------------------
9 # Leave the region name and the grid uri empty
10
11 #Teleport To Another Region On The Same Grid
12 #--------------------------------------------------------
13 #Fill in the region name but not the Grid Uri,
14
15 #Teleport To Another Region On A Different Grid
16 #--------------------------------------------------------
17 #Fill in the region name and the grid uri
18
19 #Options Description
20 #--------------------------
21 #Blank Lines and lines starting with # are ignored
22 #Landing: point is a vector <x,y,z> which represents the landing point on the destination region.
23 #LookAt: is the direction the avatar will face when they land (assuming its ever fixed)
24 #GridUri: is the URI for the destination grid. Example: http://fireandicegrid.net:8002
25 #Region: is the name of the destination region. Example: Covey Stores
26 #Image: this is the UUID/Key of the image you wish to display.
27 #Name: a descriptive name used to tell people where they are being teleported to, the board will also rename its self using this.
28
29 Landing = <132.76846, 128.44232, 23.36178>
30 LookAt = <648.81219, 84.31132, 44.19897>
31 GridUri =
32 Region = Norse Adventure
33 Image = ede3919d-433e-4cc6-841b-04e5f75bd179
34 Name =
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 <>