Home |
Add a script
|
||
|---|---|---|---|
| Category: | Contributor: | Description | |
| Map | Runay Roussel | Mapmaker | |
Retrieves map tile (texture UUID) from Subnova and displays it on a prim.
How to use: - create a cube (change texture if desired) - drop the script in it - resize as needed
Download this script - Please use this link to get this script. If you see all the code on one long line, please use Wordpad or another editor, such as LSLEdit.exe. The .LSL file you will download is an ordinary text file.
1 // Mapmaker 2 // 3 // History: 4 // 5 // - a PHP script was created by Lex Mars (founder of Subnova); it accesses the map tiles and returns a texture UUID 6 // - a small example script (including the URL) was published in the LSL Wiki Script Library 7 // - the script uses a HTTP request (I used that as a starting point) to retrieve the texture UUID of the map 8 // 9 // Added stuff: 10 // 11 // - error checking 12 // - 24 hour timer 13 // - change map on touch 14 // - set object name to "Map of ..." (hover mouse over map to see it) 15 // 16 // How to use: 17 // 18 // - create a cube (change texture if desired) 19 // - drop the script in it 20 // - resize as needed 21 // 22 // Author: Runay Roussel 23 // Released to the public domain on September 14th, 2009 24 25 float TIME = 86400.0; // timer interval = 24 hours 26 integer lsn = 0; // handle for listener 27 key request; // handle for HTTP request 29 string sim; // sim 30 string sim_old; // previous sim 31 string URL = "http://www.subnova.com/secondlife/api/map.php"; // URL of PHP script 32 string full_URL; // full URL including sim name 33 35 { 37 } 38 39 getMap(string sim_name) 40 { 41 full_URL = URL + "?sim=" + llEscapeURL(sim_name); 42 request = llHTTPRequest(full_URL, [], ""); 43 llSetTimerEvent(0); 44 llSetTimerEvent(TIME); 45 } 46 47 default 48 { 49 state_entry() 50 { 51 llSetObjectDesc("Touch to change"); 53 user = llGetOwner(); 54 sim = capitalize(llGetRegionName()); // default sim = current 55 sim_old = sim; 56 getMap(sim); // initial map display 57 } 58 60 { 61 llResetScript(); 62 } 63 65 { 66 if (status != 200) { 67 sim = sim_old; 68 if (status == 499) { 69 if (user) llInstantMessage(user, "Sim not found."); 70 } 71 else { 72 if (user) { 73 llInstantMessage(user, "An unexpected error has occurred. Return code = HTTP " + (string)status); 74 llLoadURL(user, "Full error message", full_URL); 75 } 76 } 77 } 78 else { 79 if ((key)body) { 80 llSetTexture(body, 1); 81 llSetObjectName("Mapmaker"); 82 if (user) llInstantMessage(user, "Rendering map of " + sim + "..."); 83 } 85 sim = sim_old; 86 if (user) llInstantMessage(user, "Sim exists but has not yet been mapped. Please try again later."); 87 } 88 else { 89 sim = sim_old; 90 if (user) { 91 llInstantMessage(user, "An unexpected error has occurred. Return code = HTTP " + (string)status); 92 llLoadURL(user, "Full error message", full_URL); 93 } 94 } 95 } 96 llSetObjectName("Map of " + sim); 97 } 98 99 timer()100 {101 if (lsn) {102 llListenRemove(lsn);103 lsn = 0;104 llSetTimerEvent(0);105 llSetTimerEvent(TIME);106 llInstantMessage(user, "Timeout.");107 llSetObjectName("Map of " + sim);108 }109 else {110 user = "";111 getMap(sim);112 }113 }114 115 touch_start(integer total_number)116 {117 user = llDetectedKey(0);118 llListenRemove(lsn);119 lsn = llListen(0, "", user, "");120 llSetTimerEvent(0);121 llSetTimerEvent(60);122 llSetObjectName("Mapmaker");123 llInstantMessage(user, "Please type the name of a sim within the next minute.");124 }125 127 {128 llListenRemove(lsn);129 lsn = 0;130 sim_old = sim;131 sim = capitalize(message);132 getMap(sim);133 }134 }