Don't click here unless you want to be banned.

LSL Wiki : llRequestSimulatorData

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl801.us.archive.org
key llRequestSimulatorData(string simulator, integer data)

Requests data about the sim with the name simulator. simulator is case-insensitive. Returns a dataserver query ID and triggers the dataserver event when data is found. The sim name is usually not case-sensitive, but sometimes will return data for a similarly-named sim if the supplied case doesn't match the intended sim's actual name.

For example, specifying "Heaton" for simulator will result in information about the sim "Heaven", while specifying "heaven" will return information on the sim "Heaton". There is no official word on why this happens, but one assumes that when the dataserver finds that no sim matches the case as specified, it makes a frequently bad guess.

This function delays the script for 1 second.

Data Value Description
DATA_SIM_POS 5 returns a vector (cast to a string) specifying the simulator's global position.
DATA_SIM_STATUS 6 returns a string (see table below)
DATA_SIM_RATING 7 returns a string, either "PG", "MATURE", "ADULT" or "UNKNOWN"

Data returned from DATA_SIM_STATUS request Description
"up" simulator currently up and running
"down" simulator currently down
"starting" simulator currently starting
"stopping" simulator currently stopping
"crashed" simulator has crashed
"unknown" simulator status unknown or unknown simulator name

DATA_SIM_STATUS returns the string "unknown" when querying for a nonexistant sim while DATA_SIM_POS and DATA_SIM_RATING silently fail.

Remember, calling llRequestSimulatorData to determine the sim's corner is only necessary if data is needed for a sim other than the one in which the script is currently running. If it is desired to find the global position of the current sim, llGetRegionCorner would be a wiser and more efficient choice.

Example:
key ahernStatusQuery;
key ahernPosQuery;
default
{
    touch_start(integer total_number)
    {
        ahernStatusQuery = llRequestSimulatorData("ahern", DATA_SIM_STATUS);
        ahernPosQuery = llRequestSimulatorData("ahern", DATA_SIM_POS);
    }
    dataserver(key queryId, string data) 
    {
        if (queryId == ahernStatusQuery) {
            ahernStatusQuery = "";
            llSay(0, "Status of Ahern: " + data);
        } else if (queryId == ahernPosQuery) {
            ahernPosQuery = "";
            llSay(0, "Ahern's position: " + data);
        }
    }
}

Partial list of simulators: SimulatorNames.

Q: How do I request data for the current simulator?
A: To find out the name of the sim your script is in, use llGetRegionName. If you're just planning on finding the sim corner position for the current sim, a faster and better method is to use llGetRegionCorner. You can avoid bothering with the dataserver altogether then.

Q: The values for DATA_SIM_POS and DATA_SIM_STATUS are 5 and 6, respectively. What happens if I pass 1, 2, 3, or 4 instead?
A: Nothing. Those values may or may not do something in future, at which time they would have associated constants, but they don't do anything now. One likely possibility is that all the llRequest* functions filter into the same backend function, so 1, 2, 3, and 4 would refer to the llRequestAgentData flags DATA_ONLINE, DATA_NAME, DATA_BORN, DATA_RATING respectively.


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Simulator | dataserver
Comments [Hide comments/form]
If you have multiple scripts in the same prim that use the dataserver, make sure you check the dataserver key! I got burned by this because I'd never actually read the dataserver event handler wiki page, and so didn't realize that the dataserver triggers *all* dataserver event handlers in the prim, not just the one in the script that caused it. (which should have been apparent if I'd thought about it a little bit, but I didn't).
-- NeoRebus (2006-08-20 20:24:18)
Attach a comment to this page: