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
Sim Texture Put_a_sim_map_on_a_texture  

Put_a_sim_map_on_a_texture

This version returns the Object Layer Map (i,e the default map image) but shows how you can also request the Terrain Layer Map.

Category: Sim Texture
By : Tyche Shepherd
Created: 2010-07-16 Edited: 2010-07-16
Worlds: Second Life

the Zip file

Download all files for Put_a_sim_map_on_a_texture
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Put_a_sim_map_on_a_texture_1.lsl
1 /*
2 Example script to apply a Region Map as a texture on a Prim
3 Author: Tyche Shepherd
4 Date: 2010-02-11
5 Copyright: Tyche Shepherd 2008-2010
6 License: Creative Commons Attribution 2.0 UK:England & Wales License
7
8 Basically you can do anything with this script including making derivative commercial works as long as you credit
9 Tyche Shepherd and gridsurvey.com . This credit should be distributed with any product.
10 See http://www.gridsurvey.com/api.php for more details on this license as well as any caveats.
11
12 The script sets up a listen when the container prim is touched.
13 The user then speaks the name of the desired region on the channel (default is channel 87)
14 A llHTTPRequest is sent to http://api.gridsurvey.com which returns the UUID of that Region's Map if it's found.
15 The Container Prim's texture is then changed to this UUID
16 The Listen times out after 10 seconds.
17
18 The gridsurvey.com Region Database is normally updated on a daily basis with the latest Region Maps.
19
20 */
21 key requestID;
22 integer handle;
23 integer channel;
24 string currentsim;
25 string query_string;
26
27 default
28 {
29
31 {
32 handle=0;
33 //use channel 87 for listening
34 channel=87;
35 }
36
37 touch_start(integer total_number)
38 {
39 if(handle!=0){
40 llListenRemove(handle);
41 handle=0;
42 }
43 llSay(0,"Say name of Region you want on channel " + (string)channel);
44 handle=llListen(channel,"","","");
45 //set listen time out to 10 seconds
46 llSetTimerEvent(10.0);
47
48 }
49 listen(integer channel, string name, key id, string message)
50 {
51 currentsim=message;
52 /*urlencode region name and create the query string
53 &item=objects_uuid requests the object map layer
54 &item=terrain_uuid requests the terrain map layer
55 */
56 query_string="region=" + llEscapeURL(message) + "&item=objects_uuid";
57
58 //send the request to api.gridsurvey.com
59 requestID = llHTTPRequest("http://api.gridsurvey.com/simquery.php",[HTTP_METHOD, "POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded"], query_string);
60
61
62 //close the current listen
63 llSetTimerEvent(0.0);
64 if(handle!=0)llListenRemove(handle);
65 handle=0;
66
67 }
68
69
70
71 http_response(key req_id, integer status, list meta, string body)
72 {
73 if(req_id == requestID)
74 {
75 if(llGetSubString(body, 0, 4)=="Error") {
76 //the api returned an error so report it
77 llSay(0,body);
78 } else {
79 //set the prim texture
81 llSay(0,"Current Region Map UUID for "+ currentsim + " is "+ body);
82
83 }
84
85 }
86 else
87 {
88 llSay(0,"Error: " + (string)status);
89 }
90 }
91 timer()
92 {
93 //if fired due to timeout close the listen
94 if(handle!=0){
95 llSay(0,"Region Map change timed out after 10 seconds. Please touch again to change the Region Map");
96 llListenRemove(handle);
97 handle=0;
98 }
99 llSetTimerEvent(0.0);
100 }
101
102 }

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