diff --git a/General/HG teleport board.lsl b/General/HG teleport board.lsl deleted file mode 100644 index debb452..0000000 --- a/General/HG teleport board.lsl +++ /dev/null @@ -1,447 +0,0 @@ -// This script is licensed under Creative Commons BY-NC-SA -// See -// -// You may not use this work for commercial purposes. -// You must attribute the work to the author, Jeff Kelley. -// You may distribute, alter, transform, or build upon this work -// as long as you do not delete the name of the original author. - - -integer DEBUG_ON = TRUE; -DEBUG(string message) {if (DEBUG_ON) llOwnerSay(message);} - - -/////////////////////////////////////////////////////////////////// -// Part 1 : Datasource -/////////////////////////////////////////////////////////////////// - -// The goal of the datasource is to read a file in script's memory -// At the moment, we support three datasources: -// -// http:// A web file -// card://cardname A notecard in the objects's inventory -// card://uuid/cardname A notecard from the LSL server 'uuid' -// (requires a server script, not included) -// -// Edit the 'datasource' string to fit your need -// -//string datasource = "card://Destinations"; -//string datasource = -//"card://e511d6c0-7588-4157-a684-8ca5f685a077/Destinations"; -//string datasource = "http://my_web_server/path_to_file/Destinations"; - -string datasource = "card://Destinations"; - -string datasorceData; // The content of the datasource - -readFile(string source) { - list parse = llParseString2List (source, ["/"],[]); - string s0 = llList2String (parse, 0); - string s1 = llList2String (parse, 1); - string s2 = llList2String (parse, 2); - - // Web server: fall through http_response event - - if (s0 == "http:") sendHTTPRequest (source); - - // LSL server : fall through dataserver event - // If no UUID : fall through dataserver event - - if (s0 == "card:") - if (isUUID(s1)) osMessageObject ((key)s1, "READ "+s2); - else readNotecard (s1); -} - -integer isUUID (string s) { - list parse = llParseString2List (s, ["-"],[]); - return ((llStringLength (llList2String (parse, 0)) == 8) - && (llStringLength (llList2String (parse, 1)) == 4) - && (llStringLength (llList2String (parse, 2)) == 4) - && (llStringLength (llList2String (parse, 3)) == 4) - && (llStringLength (llList2String (parse, 4)) == 12)); -} - -/////////////////// -// Notecard reader -/////////////////// - -// Since osGetNotecard has Threat Level = VeryHigh -// we stick to the old, slow, clumsy notecard reader - -string ncName; // Name of the notecard to be read -key ncQueryID; // id of dataserver queries -integer ncLine; // Current line being read - -readNotecard (string name) { - ncName = name; - ncLine = 0; - ncQueryID = llGetNotecardLine(ncName, ncLine++); // request first line -} - -addtoNotecard (string data) { - datasorceData += data+"\n"; - ncQueryID = llGetNotecardLine(ncName, ncLine++); // Request next line -} - -/////////////////// -// Http stuff -/////////////////// - -key httpQueryId; - -sendHTTPRequest (string url) { - httpQueryId = llHTTPRequest(url, - [ HTTP_METHOD, "GET", HTTP_MIMETYPE,"text/plain;charset=utf-8" ], ""); -} - -string URI2hostport (string uri) { - list parse = llParseString2List (uri, [":"], []); - return llList2String (parse, 0) - +":" + llList2String (parse, 1); -} - - -/////////////////////////////////////////////////////////////////// -// Part 2 : Parsing & accessors -/////////////////////////////////////////////////////////////////// - -list destinations; // Strided list for destinations - -integer NAME_IDX = 0; // Index of region name in list -integer COOR_IDX = 1; // Index of grid coordinates in list -integer HURL_IDX = 2; // Index of hypergrid url in list -integer HGOK_IDX = 3; // Index of validity flag in list -integer LAND_IDX = 4; // Index of landing point in list -integer N_FIELDS = 5; // Total number of fields - -parseFile (string data) { - list lines = llParseString2List (data,["\n"],[]); - integer nl = llGetListLength (lines); - integer i; for (i=0;i; - vector ourLoc = llGetRegionCorner()/256; - integer ok =( llAbs(llFloor(hisLoc.x - ourLoc.x)) < 4096 ) - && ( llAbs(llFloor(hisLoc.y - ourLoc.y)) < 4096 ) - && ( hisLoc != ourLoc); - - // Parse and check landing point - - parse = llParseString2List (coor, [","],[]); - integer xland = llList2Integer (parse, 0); // X landing point - integer yland = llList2Integer (parse, 1); // Y landing point - integer zland = llList2Integer (parse, 2); // Z landing point - - vector land = ; - if (land == ZERO_VECTOR) land = <128,128,20>; - - // Note: grid and region names merged into one field - destinations += [grid+" "+name, gloc, hurl, ok, land]; -} - -/////////////////// -// List accessors -/////////////////// - -string dst_name (integer n) { // Get name for destination n - return llList2String (destinations, N_FIELDS*n +NAME_IDX); -} - -string dst_coord (integer n) { // Get coords for destination n - return llList2String (destinations, N_FIELDS*n +COOR_IDX); -} - -vector dst_landp (integer n) { // Get landing point for destination n - return llList2Vector (destinations, N_FIELDS*n +LAND_IDX); -} - -string dst_hgurl (integer n) { // Get hypergrid url for destination n - return llList2String (destinations, N_FIELDS*n +HURL_IDX); -} - -integer dst_valid (integer n) { // Get validity flag for destination n - return llList2Integer (destinations, N_FIELDS*n +HGOK_IDX); -} - - -//////////////////////////////////////////////////////////// -// Part 3 : Drawing -//////////////////////////////////////////////////////////// - -integer TEXTURE_SIZE = 512; -integer DISPLAY_SIDE = 1; -integer FONT_SIZE = 10; // Depends on TEXTURE_SIZE -integer COLUMNS = 3; -integer ROWS = 16; - -string validCellColor = "CadetBlue"; -string invalCellColor = "IndianRed"; -string emptyCellColor = "DarkGray"; -string cellBorderColor = "White"; -string backgroundColor = "Gray"; - -string drawList; - -displayBegin() { - drawList = ""; -} - -displayEnd() { - osSetDynamicTextureData ( "", "vector", drawList, - "width:"+(string)TEXTURE_SIZE+",height:"+(string)TEXTURE_SIZE, 0); -} - -drawCell (integer x, integer y) { - integer CELL_HEIGHT = TEXTURE_SIZE / ROWS; - integer CELL_WIDHT = TEXTURE_SIZE / COLUMNS; - integer xTopLeft = x*CELL_WIDHT; - integer yTopLeft = y*CELL_HEIGHT; - - // Draw grid - - drawList = osSetPenColor (drawList, cellBorderColor); - drawList = osMovePen (drawList, xTopLeft, yTopLeft); - drawList = osDrawRectangle (drawList, CELL_WIDHT, CELL_HEIGHT); - - integer index = (y+x*ROWS); - string cellName = dst_name(index); - integer cellValid = dst_valid(index); - - string cellBbackground; - if (cellName == "") cellBbackground = emptyCellColor; else - if (cellValid) cellBbackground = validCellColor; else - cellBbackground = invalCellColor; - - // Fill background - - drawList = osSetPenColor (drawList, cellBbackground); - drawList = osMovePen (drawList, xTopLeft+2, yTopLeft+2); - drawList = osDrawFilledRectangle (drawList, CELL_WIDHT-3, CELL_HEIGHT-3); - - xTopLeft += 2; // Center text in cell - yTopLeft += 6; // Center text in cell - drawList = osSetPenColor (drawList, "Black"); - drawList = osMovePen (drawList, xTopLeft, yTopLeft); - drawList = osDrawText (drawList, cellName); -} - -drawTable() { - displayBegin(); - - drawList = osSetPenSize (drawList, 1); - drawList = osSetFontSize (drawList, FONT_SIZE); - - drawList = osMovePen (drawList, 0, 0); - drawList = osSetPenColor (drawList, backgroundColor); - drawList = osDrawFilledRectangle (drawList, TEXTURE_SIZE, TEXTURE_SIZE); - - integer x; integer y; - for (x=0; x