Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- emDash Auto Beamer, by Liace Parx
- this code is public domain, enjoy!
- Version 0.15
- */
- integer tpWhenBusy = FALSE; //Allow to be beamed up when busy?
- integer tpWhenAway = FALSE; //Allow to be beamed up when away?
- integer tpWhenSit = TRUE; //Allow to be beamed up while sitting?
- integer idleTime = 1800; //Seconds from last movement until auto beaming will be ignored, 0 = always on (default 1800 = 30 minutes)
- float sensorRepeat = 2.0; //How often the sensor should repeat (default 2.0 seconds)
- float sensorRange = 5.0; //Max range to the beam (default 5.0 meters)
- float beamThrottle = 10; //Seconds to wait from detecting a beam until script starts looking for another (default 10 seconds)
- integer sitRetry = 10; //How many times the script should try sitting on the prim before giving up (default 10)
- float sitDelay = 0.5; //Delay between retrying to sit (default 0.5 seconds)
- // Settings stop here, nothing below this line should need any changes
- string versionPaste = "Ey8XCd8D";
- key versionReply = NULL_KEY;
- float versionThis = 0.150000;
- integer lastMove = 0;
- string GetDisplayName(key id)
- {
- string name = llStringTrim(llGetDisplayName(id), STRING_TRIM);
- if (name == "" || name == "???")
- {
- name = llKey2Name(id);
- }
- return name;
- }
- startSensor()
- {
- llSensorRepeat("", NULL_KEY, SCRIPTED, sensorRange, PI, sensorRepeat); //Start a repeating sensor, looking for scripted prims, with set range and rate
- lastMove = llGetUnixTime();
- }
- pauseSensor()
- {
- llSensorRemove(); //Should stop the sensor() from finishing
- llSetTimerEvent(beamThrottle); //Wait before starting to look for a beam again
- }
- default
- {
- state_entry()
- {
- versionReply = llHTTPRequest("http://pastebin.com/raw.php?i=" + versionPaste, [], ""); //Request url from pastebin
- if (idleTime > 0) llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
- startSensor(); //Start the sensor looking for the beam
- }
- sensor(integer t)
- {
- integer i;
- for(i = 0; i < t; i++) //Run through all detected prims
- {
- if(~llSubStringIndex(llToLower(llDetectedName(i)), " beam")) //Check if the object got the word " beam" in
- {
- if (idleTime > 0 && (llGetUnixTime() - lastMove) > idleTime) //Check if a idle time is set, and if it is too long since the avi was moved last
- {
- pauseSensor();
- return;
- }
- integer buf = llGetAgentInfo(llGetOwner());
- key primOwnerKey = llGetOwnerKey(llDetectedKey(i));
- if((buf & AGENT_BUSY) && !tpWhenBusy) //Check if avi is set as busy, and if it is allowed to beam while busy
- {
- pauseSensor();
- return;
- }
- if((buf & AGENT_AWAY) && !tpWhenAway) //Check if avi is away, and if it is allowed to beam while away
- {
- pauseSensor();
- return;
- }
- if(buf & AGENT_SITTING) //Check if avi is sitting, and unsit if it is
- {
- if (!tpWhenSit)
- {
- pauseSensor();
- return; //If avi is sitting, and not allowed to beam while sitting, stop here
- }
- llOwnerSay("@unsit=force");
- llSleep(0.5);
- }
- if (primOwnerKey != llGetOwner()) llOwnerSay("You are getting beamed up by " + GetDisplayName(primOwnerKey));
- integer retry;
- for (retry = 0; retry < sitRetry; retry++) //The beam's can some times be slow to get ready, so give it a few attempts
- {
- buf = llGetAgentInfo(llGetOwner());
- if (!(buf & AGENT_SITTING))
- {
- llOwnerSay("@sit:" + (string)llDetectedKey(i) + "=force"); //Use RLV to sit on the prim
- llSleep(sitDelay);
- }
- else
- {
- retry = sitRetry; //Make the FOR loop stop here
- }
- }
- pauseSensor();
- i = t; //Make sure the loop and sensor stops
- }
- }
- }
- timer()
- {
- startSensor(); //Start the sensor again
- llSetTimerEvent(0); //Stop the timer
- }
- run_time_permissions(integer perm)
- {
- if(PERMISSION_TAKE_CONTROLS & perm) //Check if we got permission to take controls
- {
- llTakeControls(CONTROL_FWD|CONTROL_BACK|CONTROL_LEFT|CONTROL_RIGHT|CONTROL_ROT_LEFT|CONTROL_ROT_RIGHT|CONTROL_UP|CONTROL_DOWN|CONTROL_LBUTTON|CONTROL_ML_LBUTTON,TRUE,TRUE); //Take as many controls as possible
- }
- }
- control(key id, integer level, integer edge)
- {
- lastMove = llGetUnixTime(); //Save the time for the movement
- }
- attach(key id)
- {
- if(id) //Will return true when script is attached
- {
- versionReply = llHTTPRequest("http://pastebin.com/raw.php?i=" + versionPaste, [], ""); //Request url from pastebin
- startSensor();
- }
- }
- http_response(key id, integer status, list metadata, string body)
- {
- if (id == versionReply) //Check if it is the version check that is returning
- {
- string titleStart = "Version "; //Start of what we are searching for
- string titleStop = "*/"; //End of what we are searching for
- integer versionStart = llSubStringIndex(body,titleStart) + llStringLength(titleStart); //Find the position in the returned text of where start is and add the length of search string
- body = llGetSubString(body, versionStart, versionStart+10); //Cut the first away form body so body now starts right after titleSearch
- integer versionStop = llSubStringIndex(body,titleStop)-1; //Search the new cut-down body so we can find the first titleStop defined
- float versionNumber = (float)llStringTrim(llGetSubString(body, 0, versionStop), STRING_TRIM); //Turn use only what is left from first char to titleStop is detected, and turn it into a float
- if (versionNumber > versionThis) //Check if there is a newer version avalible
- {
- llOwnerSay("There is a new version of the auto beamer script avalible, get it here: http://pastebin.com/raw.php?i=" + (string)versionPaste);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement