removed useless _ folders
This commit is contained in:
3
Map_on_a_Prim/Map_on_a_Prim.sol
Normal file
3
Map_on_a_Prim/Map_on_a_Prim.sol
Normal file
@@ -0,0 +1,3 @@
|
||||
<Solution name="Map_on_a_Prim">
|
||||
<Project name="Map_on_a_Prim" path="Map_on_a_Prim\Map_on_a_Prim.prj" active="true"/>
|
||||
</Solution>
|
||||
6
Map_on_a_Prim/Map_on_a_Prim/Map_on_a_Prim.prj
Normal file
6
Map_on_a_Prim/Map_on_a_Prim/Map_on_a_Prim.prj
Normal file
@@ -0,0 +1,6 @@
|
||||
<Project name="Map_on_a_Prim" guid="D8EDEEAB-6C00-1014-B904-200204C60A89">
|
||||
<Object name="Object" guid="D8EDEFA1-6C00-1014-B904-200204C60A89">
|
||||
<Script name="Map_on_a_Prim_1.lsl" guid="D8EE587A-6C00-1014-B904-200204C60A89">
|
||||
</Script>
|
||||
</Object>
|
||||
</Project>
|
||||
485
Map_on_a_Prim/Map_on_a_Prim/Object/Map_on_a_Prim_1.lsl
Normal file
485
Map_on_a_Prim/Map_on_a_Prim/Object/Map_on_a_Prim_1.lsl
Normal file
@@ -0,0 +1,485 @@
|
||||
// :CATEGORY:Map
|
||||
// :NAME:Map_on_a_Prim
|
||||
// :AUTHOR:Honoured Resident
|
||||
// :CREATED:2013-06-14 07:57:45.040
|
||||
// :EDITED:2013-09-18 15:38:57
|
||||
// :ID:506
|
||||
// :NUM:677
|
||||
// :REV:1.0
|
||||
// :WORLD:Second Life
|
||||
// :DESCRIPTION:
|
||||
// This script uses the "Media on a Prim" feature. The following requirements should be met:
|
||||
//
|
||||
// - Viewer 2 or higher (or similar third-party viewer like Firestorm)
|
||||
// - Auto-play enabled in Preferences, Sound & Media
|
||||
//
|
||||
// FEATURES
|
||||
//
|
||||
// - Menu-controlled
|
||||
// - Display any region map
|
||||
// - Map updates every 12 hours
|
||||
// - Zoom in or out
|
||||
// - Map teleporter
|
||||
// - Access control: owner, group, world
|
||||
//
|
||||
// LIMITATIONS
|
||||
//
|
||||
// - Media prims may cause performance problems if not used sparingly
|
||||
// - Because of several unsupported hacks, the script cannot be guaranteed to work forever
|
||||
// - If something does break, the script may temporarily or permanently disable the zoom feature
|
||||
// - If the requested map tile does not exist on map.secondlife.com (but the region exists and is online),
|
||||
// the server will return a "NoSuchKey" error and display it on the prim. The map tile should be available
|
||||
// within 24-48 hours
|
||||
//
|
||||
// PUTTING IT ALL TOGETHER
|
||||
//
|
||||
// A media prim cannot be touched in the usual way, so a bit of trickery is needed to make it work.
|
||||
//
|
||||
// 1. Create two plywood cubes (Shift+drag), link them and leave some space in between
|
||||
// 2. Drop the script on the linked object and read the instructions
|
||||
// 3. Resize and/or texture as needed
|
||||
//
|
||||
// The end result should be like a painting covered by a sheet of glass. If you decide to add a frame, make
|
||||
// sure the media prim is the last one you touch before linking. That way, it will always end up as the root.
|
||||
// The map will always be displayed on face 1 of the root prim, no matter where the script is.
|
||||
// :CODE:
|
||||
// Map on a Prim
|
||||
|
||||
//
|
||||
|
||||
// Sim map displayed as "media on a prim"
|
||||
|
||||
//
|
||||
|
||||
// Author: Honoured Resident
|
||||
|
||||
// Date: 01-12-2012
|
||||
|
||||
//
|
||||
|
||||
// This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License (CC BY-NC 3.0).
|
||||
|
||||
// To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/.
|
||||
|
||||
//
|
||||
|
||||
// Author and license headers must be left intact.
|
||||
|
||||
|
||||
|
||||
string title = "Map on a Prim"; // title
|
||||
|
||||
string version = "1.0"; // version
|
||||
|
||||
|
||||
|
||||
// Timer constants
|
||||
|
||||
//
|
||||
|
||||
// Will be assigned to variable "time" and checked in timer event
|
||||
|
||||
// Important: this only works if all timer intervals are different!
|
||||
|
||||
//
|
||||
|
||||
// Always remember to destroy or reassign the timer when:
|
||||
|
||||
// - the timed event has occurred within the allotted time (success)
|
||||
|
||||
// - the timer has expired (failure)
|
||||
|
||||
|
||||
|
||||
float cDialogTime = 300.0; // dialog timeout = 5 minutes
|
||||
|
||||
float cListenTime = 60.0; // listener timeout = 1 minute
|
||||
|
||||
float cRequestTime = 10.0; // dataserver timeout = 10 seconds
|
||||
|
||||
float cUpdateTime = 43200.0; // map update = 12 hours
|
||||
|
||||
|
||||
|
||||
// Access constants
|
||||
|
||||
|
||||
|
||||
integer cOwner = 4; // owner access bit
|
||||
|
||||
integer cGroup = 2; // group access bit
|
||||
|
||||
integer cWorld = 1; // world access bit
|
||||
|
||||
|
||||
|
||||
// Other constants
|
||||
|
||||
|
||||
|
||||
integer cDebug = FALSE; // show/hide debug messages
|
||||
|
||||
integer cPrim = LINK_ROOT; // prim for displaying media
|
||||
|
||||
integer cPrimFace = 1; // prim face for media
|
||||
|
||||
string cProxy = "http://anonymouse.org/cgi-bin/anon-www.cgi/"; // anonymouse proxy
|
||||
|
||||
string cSLURL = "http://slurl.com/get-region-name-by-coords?var=region"; // slurl.com
|
||||
|
||||
string cURL = "http://map.secondlife.com/"; // amazon S3
|
||||
|
||||
|
||||
|
||||
// Variables
|
||||
|
||||
|
||||
|
||||
float time; // timer interval for various timers (see timer constants above)
|
||||
|
||||
float vRequestTime; // variable timeout for dataserver event, ranging from 10 to 20 sec.
|
||||
|
||||
integer advanced; // disable or enable advanced features (TRUE or FALSE)
|
||||
|
||||
integer allow_touch; // disable or enable touching (TRUE or FALSE)
|
||||
|
||||
integer dlgChannel; // dialog channel
|
||||
|
||||
integer dlgHandle; // handle for dialog channel
|
||||
|
||||
integer lsn; // handle for listener
|
||||
|
||||
integer map_teleport; // teleport on touch (TRUE or FALSE)
|
||||
|
||||
integer menu_access; // access level for menu
|
||||
|
||||
integer seqnr; // sequence number for unique URLs
|
||||
|
||||
integer zoom_level; // zoom level (1-8)
|
||||
|
||||
integer zoom_level_old; // previous zoom level
|
||||
|
||||
key owner; // owner
|
||||
|
||||
key query_pos; // dataserver query, retrieves sim position
|
||||
|
||||
key query_status; // dataserver query, retrieves sim status
|
||||
|
||||
key request; // handle for HTTP request
|
||||
|
||||
key user; // key of user touching the prim
|
||||
|
||||
string full_URL; // full URL including sim offset and zoom level
|
||||
|
||||
string sim_name; // simulator name
|
||||
|
||||
string sim_name_old; // previous simulator name
|
||||
|
||||
vector map_coord; // global region coordinates returned by dataserver event
|
||||
|
||||
vector map_coord_old; // previous region coordinates returned by dataserver event
|
||||
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
|
||||
|
||||
integer accessGranted(key user, integer access)
|
||||
|
||||
{
|
||||
|
||||
integer bitmask = cWorld;
|
||||
|
||||
if (user == owner) bitmask += cOwner;
|
||||
|
||||
if (llSameGroup(user)) bitmask += cGroup;
|
||||
|
||||
return (bitmask & access);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
string capWords (string name)
|
||||
|
||||
{
|
||||
|
||||
integer i;
|
||||
|
||||
string word;
|
||||
|
||||
string newname;
|
||||
|
||||
list lst = llParseString2List(name, [" "], []);
|
||||
|
||||
integer len = llGetListLength(lst);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
|
||||
word = llList2String(lst, i);
|
||||
|
||||
newname += llToUpper(llGetSubString(word, 0, 0)) + llGetSubString(word, 1, -1) + " ";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return llStringTrim(newname, STRING_TRIM_TAIL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
float setTimer(float sec)
|
||||
|
||||
{
|
||||
|
||||
llSetTimerEvent(0.0);
|
||||
|
||||
llSetTimerEvent(sec);
|
||||
|
||||
return sec;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
key getSimulatorData(string name, integer data)
|
||||
|
||||
{
|
||||
|
||||
allow_touch = FALSE;
|
||||
|
||||
float pctlag = 100.0 * (1.0 - llGetRegionTimeDilation()); // try to work around time dilation
|
||||
|
||||
vRequestTime = cRequestTime + cRequestTime / 100.0 * pctlag; // (more lag = longer timeout)
|
||||
|
||||
time = setTimer(vRequestTime);
|
||||
|
||||
return llRequestSimulatorData(name, data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
setPrimImage(integer prim, integer face, string image)
|
||||
|
||||
{
|
||||
|
||||
llSetLinkMedia(prim, face, [
|
||||
|
||||
PRIM_MEDIA_CURRENT_URL, image,
|
||||
|
||||
PRIM_MEDIA_AUTO_PLAY, TRUE,
|
||||
|
||||
PRIM_MEDIA_AUTO_SCALE, FALSE,
|
||||
|
||||
PRIM_MEDIA_WIDTH_PIXELS, 256,
|
||||
|
||||
PRIM_MEDIA_HEIGHT_PIXELS, 256,
|
||||
|
||||
PRIM_MEDIA_PERMS_CONTROL, PRIM_MEDIA_PERM_NONE,
|
||||
|
||||
PRIM_MEDIA_PERMS_INTERACT, PRIM_MEDIA_PERM_NONE
|
||||
|
||||
]);
|
||||
|
||||
|
||||
|
||||
if (zoom_level == 1) llSetLinkPrimitiveParamsFast(prim, [PRIM_DESC, sim_name + " (touch for menu)"]);
|
||||
|
||||
else llSetLinkPrimitiveParamsFast(prim, [PRIM_DESC, "Touch the map to select a region"]);
|
||||
|
||||
|
||||
|
||||
allow_touch = TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
setPrimText(integer prim, integer face, string text)
|
||||
|
||||
{
|
||||
|
||||
llSetLinkMedia(prim, face, [
|
||||
|
||||
PRIM_MEDIA_CURRENT_URL, "data:text/html," + text,
|
||||
|
||||
PRIM_MEDIA_AUTO_PLAY, TRUE,
|
||||
|
||||
PRIM_MEDIA_AUTO_SCALE, FALSE,
|
||||
|
||||
PRIM_MEDIA_WIDTH_PIXELS, 256,
|
||||
|
||||
PRIM_MEDIA_HEIGHT_PIXELS, 256,
|
||||
|
||||
PRIM_MEDIA_PERMS_CONTROL, PRIM_MEDIA_PERM_NONE,
|
||||
|
||||
PRIM_MEDIA_PERMS_INTERACT, PRIM_MEDIA_PERM_NONE
|
||||
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
showMap(integer prim, integer face, vector sim_coord, integer z)
|
||||
|
||||
{
|
||||
|
||||
integer x = (integer)(sim_coord.x / 256.0);
|
||||
|
||||
integer y = (integer)(sim_coord.y / 256.0);
|
||||
|
||||
x = x - (x % (integer)llPow(2.0, (float)z - 1.0));
|
||||
|
||||
y = y - (y % (integer)llPow(2.0, (float)z - 1.0));
|
||||
|
||||
map_coord_old = map_coord; // global
|
||||
|
||||
zoom_level_old = zoom_level; // global
|
||||
|
||||
map_coord = <(float)x * 256.0, (float)y * 256.0, 0.0>; // global
|
||||
|
||||
seqnr++;
|
||||
|
||||
if (seqnr == DEBUG_CHANNEL) seqnr = 1; // debug channel = max. int.
|
||||
|
||||
full_URL = cURL + "map-" + (string)z + "-" + (string)x + "-" + (string)y + "-objects.jpg?" + (string)seqnr;
|
||||
|
||||
|
||||
|
||||
if (z == 1) {
|
||||
|
||||
string proxy_URL = cProxy + cSLURL + "&grid_x=" + (string)x + "&grid_y=" + (string)y;
|
||||
|
||||
if (user) llInstantMessage(user, "Requesting map tile...");
|
||||
|
||||
if (advanced) request = llHTTPRequest(proxy_URL, [], ""); // will reset timer (dataserver timeout)
|
||||
|
||||
else query_status = getSimulatorData(sim_name, DATA_SIM_STATUS); // request sim status
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
if (user) llInstantMessage(user, "Loading level " + (string)z + " map tile...");
|
||||
|
||||
setPrimImage(prim, face, full_URL); // will reset timer (map update)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
showZoom(vector sim_coord, integer z, vector touch_pos)
|
||||
|
||||
{
|
||||
|
||||
float tiles = llPow(2.0, (float)z - 1.0);
|
||||
|
||||
integer tile_x = llCeil(tiles * touch_pos.x);
|
||||
|
||||
integer tile_y = llCeil(tiles * touch_pos.y);
|
||||
|
||||
integer x = (integer)(sim_coord.x / 256.0);
|
||||
|
||||
integer y = (integer)(sim_coord.y / 256.0);
|
||||
|
||||
x = x + tile_x - 1;
|
||||
|
||||
y = y + tile_y - 1;
|
||||
|
||||
map_coord_old = map_coord; // global
|
||||
|
||||
zoom_level_old = zoom_level; // global
|
||||
|
||||
map_coord = <(float)x * 256.0, (float)y * 256.0, 0.0>; // global
|
||||
|
||||
zoom_level = 1; // global
|
||||
|
||||
seqnr++;
|
||||
|
||||
if (seqnr == DEBUG_CHANNEL) seqnr = 1; // debug channel = max. int.
|
||||
|
||||
full_URL = cURL + "map-" + (string)z + "-" + (string)x + "-" + (string)y + "-objects.jpg?" + (string)seqnr;
|
||||
|
||||
full_URL = cURL + "map-1-" + (string)x + "-" + (string)y + "-objects.jpg";
|
||||
|
||||
string proxy_URL = cProxy + cSLURL + "&grid_x=" + (string)x + "&grid_y=" + (string)y;
|
||||
|
||||
if (user) llInstantMessage(user, "Requesting map tile...");
|
||||
|
||||
request = llHTTPRequest(proxy_URL, [], ""); // will reset timer (dataserver timeout)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
teleport (integer prim, string region, vector pos)
|
||||
|
||||
{
|
||||
|
||||
map_teleport = FALSE;
|
||||
|
||||
vector dest = <pos.x * 255.0, pos.y * 255.0, 0.0>;
|
||||
|
||||
llSetLinkPrimitiveParamsFast(prim, [PRIM_DESC, region + " (touch for menu)"]);
|
||||
|
||||
llMapDestination(region, dest, dest);
|
||||
|
||||
llMapDestination(region, dest, dest);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
menuDialog(key id)
|
||||
|
||||
{
|
||||
|
||||
string message;
|
||||
|
||||
list menuButtons;
|
||||
|
||||
|
||||
|
||||
if (advanced) {
|
||||
|
||||
message = "\nYou can change the map,\nteleport to the region\nor zoom out to level 2-8";
|
||||
|
||||
menuButtons = [ "6", "7", "8", "3", "4", "5", "Change map", "Teleport", "2" ];
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
message = "\n";
|
||||
|
||||
menuButtons = [ "Change map", "Teleport", "Advanced"];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (id == owner) menuButtons = llListInsertList(menuButtons, ["Owner", "Group", "World"], 0);
|
||||
|
||||
|
||||
|
||||
dlgChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
|
||||
|
||||
llListenRemove(dlgHandle);
|
||||
|
||||
dlgHandle = llListen(dlgChannel, "", id, "");
|
||||
|
||||
time = setTimer(cDialogTime);
|
||||
|
||||
llDialog(id, message, menuButtons, dlgChannel);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user