llGetSimulatorHostname
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: string llGetSimulatorHostname( );283 | Function ID |
10.0 | Forced Delay |
10.0 | Energy |
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.
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 = "// 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 |