OSSL Script Library/Teleport Map
From OpenSimulator
(Difference between revisions)
m |
m |
||
Line 34: | Line 34: | ||
region_size = (integer)size.x; // Because the length and the width of a region MUST be equal, we only need one of the floats from the vector. | region_size = (integer)size.x; // Because the length and the width of a region MUST be equal, we only need one of the floats from the vector. | ||
refresh(); // Refresh the map texture | refresh(); // Refresh the map texture | ||
− | llSetTimerEvent(timeout); // And now we make | + | llSetTimerEvent(timeout); // And now we make sure that the map texture gets updated every X seconds. (default 60) |
} | } | ||
touch_start(integer numdet) | touch_start(integer numdet) | ||
{ | { | ||
− | if(llDetectedTouchFace(0) != face) return; // If the prim is not touched on the | + | if(llDetectedTouchFace(0) != face) return; // If the prim is not touched on the side with the map, then do nothing. |
key toucher = llDetectedKey(0); // Get the UUID of the person that touched the map. | key toucher = llDetectedKey(0); // Get the UUID of the person that touched the map. | ||
vector target = llDetectedTouchUV(0); // Find out where the map has been touched | vector target = llDetectedTouchUV(0); // Find out where the map has been touched |
Latest revision as of 02:53, 14 December 2017
This script will put a region map on the containing prim, and will instantly teleport the user to the map location that they clicked on.
The code contains a lot of comments, explaining what does what, and why it is there.
// ----------------------- // ++++ TELEPORT MAP ++++ // by FRITIGERN GOTHLY // Version 1.1 // ----------------------- // Put a region map on a prim, and use that to teleport around. // This teleport system is amazingly accurate. // Do note that when a change is made to the region, the map on the // teleporter will only be updated when the rest of the world map is updated. key map; // This is where the texture UUID will be stored. integer timeout = 60; // This many seconds for the map to refresh. integer region_size; // We need this to do a little math later. integer face = 4; // Which side of the prim the map should appear on. refresh(){ map = osGetMapTexture(); // Get the map texture llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_TEXTURE, face, map, <1.0,1.0,0>, <0,0,0>, 0, // Put the map texture on the chosen side of a prim PRIM_COLOR,face,<1,1,1>,1, // Set the color of the chosen side to white. PRIM_FULLBRIGHT,face,1]); // Set the chosen side to full bright. } default { state_entry() { vector size = osGetRegionSize(); // Find out how large the region is. region_size = (integer)size.x; // Because the length and the width of a region MUST be equal, we only need one of the floats from the vector. refresh(); // Refresh the map texture llSetTimerEvent(timeout); // And now we make sure that the map texture gets updated every X seconds. (default 60) } touch_start(integer numdet) { if(llDetectedTouchFace(0) != face) return; // If the prim is not touched on the side with the map, then do nothing. key toucher = llDetectedKey(0); // Get the UUID of the person that touched the map. vector target = llDetectedTouchUV(0); // Find out where the map has been touched target.x = (region_size*target.x); // Multiply the X-position of where the map was touched with the region size. This changes value of the vector target.y = (region_size*target.y); // Multiply the Y-position of where the map was touched with the region size. This changes value of the vector osTeleportAgent(toucher, target, ZERO_VECTOR); // Teleport the person who touched the prim to the corresponding coordinates in the region. } timer() { refresh(); // Refresh the map when the timer runs out. } on_rez(integer start_param) { llResetScript(); // Reset the script when rezzed to ensure a fresh map on the prim. } }