Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Map Mapmaker_2_media_version  

Mapmaker_2_media_version

Make sure the media stream is active by either setting it to play automatically or by clicking the start button in your SL viewer.

Category: Map
By : Runay Roussel
Created: 2010-11-03 Edited: 2010-11-03
Worlds: Second Life

the Zip file

Download all files for Mapmaker_2_media_version
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Mapmaker_2_media_version_1.lsl
1 // Mapmaker 2
2 //
3 // Unlike Mapmaker 1, this version does not retrieve texture UUIDs from Subnova but jpeg images from Amazon S3
4 //
5 // Upside: these are the "official" SL map tiles
6 // Downside: jpeg images can only be displayed as media and can therefore only be used on owned/rented land
7 // Future: HTTP Texture?
8 //
9 // Author: Runay Roussel
10 // Released to the public domain on September 14th, 2009
11
12 float TIME = 43200.0; // timer interval = 12 hours
13 string URL = "http://map.secondlife.com/"; // Amazon S3
14 vector DA_BOOM = <256000.0, 256000.0, 0.0>; // global region coordinates of Da Boom
15
16 integer dlgChannel; // dialog channel
17 integer dlgHandle; // handle for dialog channel
18 integer lsn; // handle for listener
19 integer map_teleport; // teleport on touch (TRUE or FALSE)
20 integer touchFace; // map face has been touched
21 integer waiting; // waiting for data
22 integer zoom_level = 1; // zoom level (1-8)
23 integer zoom_level_old; // previous zoom level
24 key media_texture; // media texture
25 key owner; // owner
26 key query; // dataserver query
27 key request; // handle for HTTP request
28 key user; // key of user touching the prim
29 string full_URL; // full URL including sim offset and zoom level
30 vector map_coord; // global region coordinates returned by dataserver event
31 vector map_coord_old; // previous region coordinates returned by dataserver event
32
33 showMap(vector sim_coord, integer z)
34 {
35 integer x = (integer)(sim_coord.x / 256.0);
36 integer y = (integer)(sim_coord.y / 256.0);
37 x = x - (x % (integer)llPow(2.0, (float)z - 1.0));
38 y = y - (y % (integer)llPow(2.0, (float)z - 1.0));
39 map_coord_old = map_coord; // global
40 zoom_level_old = zoom_level; // global
41 map_coord = <(float)x * 256.0, (float)y * 256.0, 0.0>; // global
42 full_URL = URL + "map-" + (string)z + "-" + (string)x + "-" + (string)y + "-objects.jpg";
43 if(user) {
44 if(z == 1) llInstantMessage(user, "Requesting map...");
45 else llInstantMessage(user, "Requesting level " + (string)z + " map...");
46 }
48 llSetTimerEvent(TIME);
49 request = llHTTPRequest(full_URL, [], "");
50 }
51
52 showZoom(vector sim_coord, integer z, vector touch_pos)
53 {
54 touchFace = TRUE;
55 float tiles = llPow(2.0, (float)z - 1.0);
56 integer tile_x = llCeil(tiles * touch_pos.x);
57 integer tile_y = llCeil(tiles * touch_pos.y);
58 integer x = (integer)(sim_coord.x / 256.0);
59 integer y = (integer)(sim_coord.y / 256.0);
60 x = x + tile_x - 1;
61 y = y + tile_y - 1;
62 map_coord_old = map_coord; // global
63 zoom_level_old = zoom_level; // global
64 map_coord = <(float)x * 256.0, (float)y * 256.0, 0.0>; // global
65 zoom_level = 1; // global
66 full_URL = URL + "map-1-" + (string)x + "-" + (string)y + "-objects.jpg";
67 if(user) llInstantMessage(user, "Requesting map...");
69 llSetTimerEvent(TIME);
70 request = llHTTPRequest(full_URL, [], "");
71 }
72
73 teleport (vector sim_coord)
74 {
75 map_teleport = FALSE;
76 llSetObjectDesc("Touch for menu");
77 vector dest = sim_coord - DA_BOOM + <128.0, 128.0, 0.0>;
78 llMapDestination("Da Boom", dest, dest);
79 llMapDestination("Da Boom", dest, dest);
80 }
81
82 menuDialog(key id)
83 {
84 string message = "\nTo change the zoom level, click on a number";
85 list menuButtons;
86 if(zoom_level == 1) menuButtons =
87 [ "On", "Off", "Reset", "6", "7", "8", "3", "4", "5", "Change map", "Teleport", "2" ];
88 else menuButtons = [ "On", "Off", "Reset", "6", "7", "8", "3", "4", "5", "Change map", "1", "2" ];
89 dlgChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
90 llListenRemove(dlgHandle);
91 dlgHandle = llListen(dlgChannel, "", id, "");
93 llSetTimerEvent(120);
94 llDialog(id, message, menuButtons, dlgChannel);
95 }
96
97 default
98 {
100 {
101 owner = llGetOwner();
102 user = owner;
103 llSetObjectDesc("Touch for menu");
105 llInstantMessage(user, "Requesting data...");
106 waiting = TRUE;
109 query = llRequestSimulatorData(llGetRegionName(), DATA_SIM_POS); // initial map display
110 }
111
112 on_rez(integer start_param)
113 {
115 }
116
117 http_response(key request_id, integer status, list metadata, string body)
118 {
119 key media_texture_old = media_texture;
121 media_texture = llList2Key(media_data, 0);
122
123 if(media_data == []) {
124 if(user) llInstantMessage(user, "No permission to set or query parcel media.");
125 return;
126 }
127
128 if(status != 200 && status != 415 && status != 404) {
129 map_coord = map_coord_old;
130 zoom_level = zoom_level_old;
131 if(user) {
133 "An unexpected error has occurred. Return code = HTTP " + (string)status + ".");
134 llLoadURL(user, "Full error message", full_URL);
135 }
136 }
137 else if(status == 404) {
138 map_coord = map_coord_old;
139 zoom_level = zoom_level_old;
140 if(user) {
141 if(touchFace) llInstantMessage(user, "There is no sim at this location.");
142 else llInstantMessage(user, "There is no map tile for this location.");
143 }
144 }
145 else {
146 if(media_texture == NULL_KEY) {
147 media_texture = TEXTURE_MEDIA;
149 if(user) llInstantMessage(user,
150 "Parcel has no media texture. Setting parcel media texture to \"Default Media Texture\"...");
151 }
152 if(media_texture != media_texture_old) {
153 llSetTexture(media_texture, 1);
154 if(user) llInstantMessage(user, "Applying media texture to prim...");
155 }
157 PARCEL_MEDIA_COMMAND_TYPE, "image/jpeg",
160 ]);
161 if(zoom_level == 1) llSetObjectDesc("Touch for menu");
162 else llSetObjectDesc("Touch the map to select a region");
163 }
164 touchFace = FALSE;
165 }
166
167 timer()
168 {
169 if(dlgHandle) { // dialog timeout
170 llListenRemove(dlgHandle);
171 dlgHandle = 0;
173 llSetTimerEvent(TIME);
174 }
175 else if(lsn) { // listener timeout
176 llListenRemove(lsn);
177 lsn = 0;
179 llSetTimerEvent(TIME);
180 llInstantMessage(user, "Timeout.");
181 }
182 else if(waiting) { // dataserver timeout
183 waiting = FALSE;
185 llSetTimerEvent(TIME);
186 llInstantMessage(user, "Sim not found.");
187 }
188 else { // map update
189 user = "";
190 showMap(map_coord, zoom_level);
191 }
192 }
193
194 touch_start(integer total_number)
195 {
196 vector touchedpos = llDetectedTouchST(0);
197 user = llDetectedKey(0);
198
199 if(zoom_level == 1) {
200 if(map_teleport) teleport(map_coord);
201 else menuDialog(user);
202 }
203 else {
204 if(llDetectedTouchFace(0) == -1) {
205 llInstantMessage(user, "Viewer does not support touched faces. Displaying menu...");
206 menuDialog(user);
207 }
208 else if(llDetectedTouchFace(0) != 1) {
209 llInstantMessage(user, "Wrong side. The map is on the front.");
210 }
211 else if(touchedpos == TOUCH_INVALID_TEXCOORD) {
212 llInstantMessage(user, "Touch position could not be determined. Displaying menu...");
213 menuDialog(user);
214 }
215 else {
216 showZoom(map_coord, zoom_level, touchedpos);
217 }
218 }
219 }
220
221 listen(integer channel, string name, key id, string msg)
222 {
223 if(channel == dlgChannel) {
224 llListenRemove(dlgHandle);
225 dlgHandle = 0;
226 if(msg == "Change map") {
227 zoom_level = 1;
228 llListenRemove(lsn);
229 lsn = llListen(0, "", id, "");
232 llInstantMessage(id, "Please type the name of a sim within the next minute.");
233 }
234 else if(msg == "Teleport") {
235 map_teleport = TRUE;
236 llSetObjectDesc("Touch for map teleport");
237 llInstantMessage(id, "Touch the map to display the World Map, then click \"Teleport\"");
238 }
239 else if(msg == "On") {
241 }
242 else if(msg == "Off") {
244 }
245 else if(msg == "Reset") {
247 }
248 else {
249 zoom_level = (integer)msg;
250 showMap(map_coord, zoom_level);
251 }
252 }
253 else {
254 llListenRemove(lsn);
255 lsn = 0;
256 waiting = TRUE;
257 llInstantMessage(id, "Requesting data...");
261 }
262 }
263
264 dataserver(key requested, string data)
265 {
266 waiting = FALSE;
267 map_coord = (vector)data;
268 showMap(map_coord, zoom_level);
269 }
270 }

Back to the Best Free Tools in Second Life and OpenSim.