llGetSimulatorHostname

From Second Life Wiki
Revision as of 11:17, 24 June 2013 by Miranda Umino (talk | contribs)
Jump to navigation Jump to search

Summary

Function: string llGetSimulatorHostname( );

Returns a string that is the hostname of the machine the script is running on (same as string in viewer Help dialog)

Caveats

  • This function causes the script to sleep for 10.0 seconds.
All Issues ~ Search JIRA for related Bugs

Examples

<lsl> // The beginnings of a region-info script. string region; string sim;

default {

   state_entry()
   {
       llSetTimerEvent(1.0);
   }
   timer()
   {
       string here = llGetRegionName();
       if(region != here)
       {
           sim = llGetSimulatorHostname();
           region = here;
       }
       llSetText(
               "   REGION NAME : " + region + 
             "\n  SIM HOSTNAME : " + sim + 
             "\nTIME DIALATION : " + (string)llGetRegionTimeDilation() +
             "\n    REGION FPS : " + (string)llGetRegionFPS(),
           <0,1,0>, 1.0);
   }

} </lsl> <lsl> // Alternative method by Silky Mesmeriser // This example is more complex than the direct llGetSimulatorHostname() call however it avoids the // imposed delay of the ll function and is useful sometimes if the undue delay is a problem for your // script. Of course HTTP transactions to third party services like this can fail at times thus this // example will fall back to the LSL function with it's delay if it is unable to successfully get // the hostname from the selected third party source.

string HOSTNAME_URI = "http://www.displaymyhostname.com/"; // URL to grab hostname from

string HOSTNAME_START = "
"; // What to look for before the hostname string string HOSTNAME_END = "
"; // What marks the end of the hostname string

// Variable to store the simulator hostname set initially to Pending... to inform the end user // if they request the information from the object prior to successful retrieval. string g_sSimHost = "Pending..."; key g_kHostReqID; // Variable to store the HTTP request ID so we can handle the correct http_response

string smReadHostname(string sData) { // Parse the reply from the remote server and grab the hostname

   integer iIndex = llSubStringIndex(sData, HOSTNAME_START);
   sData = llGetSubString(sData, iIndex + llStringLength(HOSTNAME_START), llStringLength(sData));
   iIndex = llSubStringIndex(sData, HOSTNAME_END);
   sData = llGetSubString(sData, 0, iIndex -1);
   // Sanity check the hostname it should end with .lindenlab.com and not contain any characters like spaces or newlines
   // If this is untrue for some reason it's very likely that something on the page changed making it parse incorrectly
   // and thus the result can't be trusted.
if (llSubStringIndex(sData, ".lindenlab.com") != (llStringLength(sData) - llStringLength(".lindenlab.com"))

See Also

Functions

•  llGetRegionFPS Gets the region FPS
•  llGetRegionTimeDilation Gets the region time dilation

Articles

•  Simulator IP Addresses

Deep Notes

Search JIRA for related Issues

Signature

function string llGetSimulatorHostname();