Hal Canary (hwc) wrote in sl_creators,
Hal Canary
hwc
sl_creators

SLURL Generator

Info on the secondlife: URI scheme
// SLURL Generator.
// SLURL Generator.
// To use, put this script inside an invisible
// prim, then attach and detach it.

// str_replace Function licensed under CC-by v3.0 license
//   http://creativecommons.org/licenses/by/3.0/
// From http://wiki.secondlife.com/wiki/Combined_Library
string str_replace(string src, string from, string to)
{//replaces all occurrences of 'from' with 'to' in 'src'.
  integer len = (~-(llStringLength(from)));
  if(~len)
  {
    string  buffer = src;
    integer b_pos = -1;
    integer to_len = (~-(llStringLength(to)));
    @loop;//instead of a while loop, saves 5 bytes (and run faster).
    integer to_pos = ~llSubStringIndex(buffer, from);
    if(to_pos)
    {
      // b_pos -= to_pos;
      // src = llInsertString(llDeleteSubString(src, b_pos, b_pos + len),
      //  b_pos, to);
      // b_pos += to_len;
      // buffer = llGetSubString(src, (-~(b_pos)), 0x8000);
      buffer = llGetSubString(src = llInsertString(
        llDeleteSubString(src, b_pos -= to_pos, b_pos + len), b_pos, to), 
        (-~(b_pos += to_len)), 0x8000);
      jump loop;
    }
  }
  return src;
}

// Gen_SLURL function written 2008 by Hal Canary.
// Dedicated to the Public Domain.
string gen_slurl() {
  vector position = llGetPos();
  string slurlbit = str_replace(llGetRegionName( )," ","%20")
    + "/" + (string)((integer)position.x)
    + "/" + (string)((integer)position.y)
    + "/" + (string)((integer)position.z) + "/" ;
  //return "http://slurl.com/secondlife/" + slurlbit ;
  return "secondlife://" + slurlbit ;
}

// the rest written 2008 by Hal Canary.
// Dedicated to the Public Domain.
default {
  state_entry() {
    llOwnerSay(gen_slurl());
  }
  attach(key id) {
    llOwnerSay(gen_slurl());
  }
  touch_start(integer total_number) {
    llOwnerSay(gen_slurl());
  }
}


Alternativly,

How to turn a Landmark into a Slurl:
1) Right-click the LM in your inventory.
2) Choose "About Landmark" from the context menu.
3) In the landmark description window, click "Show on Map."
4) When the World Map window shows up, click "Copy SLURL to clipboard."
5) Use Ctrl-v to paste it anywhere.

How to create a Slurl for your current avatar position:
1) Open the World Map (Ctrl-m).
2) Click "Copy SLURL to clipboard."
3) Use Ctrl-v to paste it anywhere.
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded 

  • 0 comments