Advertisement
bld

0.15

bld
Apr 13th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.85 KB | None | 0 0
  1. /*
  2. emDash Auto Beamer, by Liace Parx
  3. this code is public domain, enjoy!
  4.  
  5. Version 0.15
  6. */
  7.  
  8. integer tpWhenBusy = FALSE; //Allow to be beamed up when busy?
  9. integer tpWhenAway = FALSE; //Allow to be beamed up when away?
  10. integer tpWhenSit = TRUE; //Allow to be beamed up while sitting?
  11.  
  12. integer idleTime = 1800; //Seconds from last movement until auto beaming will be ignored, 0 = always on (default 1800 = 30 minutes)
  13.  
  14. float sensorRepeat = 2.0; //How often the sensor should repeat (default 2.0 seconds)
  15. float sensorRange = 5.0; //Max range to the beam (default 5.0 meters)
  16.  
  17. float beamThrottle = 10; //Seconds to wait from detecting a beam until script starts looking for another (default 10 seconds)
  18.  
  19. integer sitRetry = 10; //How many times the script should try sitting on the prim before giving up (default 10)
  20. float sitDelay = 0.5; //Delay between retrying to sit (default 0.5 seconds)
  21.  
  22.  
  23.  
  24. // Settings stop here, nothing below this line should need any changes
  25.  
  26. string versionPaste = "Ey8XCd8D";
  27. key versionReply = NULL_KEY;
  28. float versionThis = 0.150000;
  29. integer lastMove = 0;
  30.  
  31. string GetDisplayName(key id)
  32. {
  33. string name = llStringTrim(llGetDisplayName(id), STRING_TRIM);
  34. if (name == "" || name == "???")
  35. {
  36. name = llKey2Name(id);
  37. }
  38. return name;
  39. }
  40.  
  41. startSensor()
  42. {
  43. llSensorRepeat("", NULL_KEY, SCRIPTED, sensorRange, PI, sensorRepeat); //Start a repeating sensor, looking for scripted prims, with set range and rate
  44. lastMove = llGetUnixTime();
  45. }
  46.  
  47. pauseSensor()
  48. {
  49. llSensorRemove(); //Should stop the sensor() from finishing
  50. llSetTimerEvent(beamThrottle); //Wait before starting to look for a beam again
  51. }
  52.  
  53. default
  54. {
  55. state_entry()
  56. {
  57. versionReply = llHTTPRequest("http://pastebin.com/raw.php?i=" + versionPaste, [], ""); //Request url from pastebin
  58. if (idleTime > 0) llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
  59. startSensor(); //Start the sensor looking for the beam
  60. }
  61.  
  62. sensor(integer t)
  63. {
  64. integer i;
  65.  
  66. for(i = 0; i < t; i++) //Run through all detected prims
  67. {
  68. if(~llSubStringIndex(llToLower(llDetectedName(i)), " beam")) //Check if the object got the word " beam" in
  69. {
  70. 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
  71. {
  72. pauseSensor();
  73. return;
  74. }
  75.  
  76. integer buf = llGetAgentInfo(llGetOwner());
  77. key primOwnerKey = llGetOwnerKey(llDetectedKey(i));
  78.  
  79. if((buf & AGENT_BUSY) && !tpWhenBusy) //Check if avi is set as busy, and if it is allowed to beam while busy
  80. {
  81. pauseSensor();
  82. return;
  83. }
  84.  
  85. if((buf & AGENT_AWAY) && !tpWhenAway) //Check if avi is away, and if it is allowed to beam while away
  86. {
  87. pauseSensor();
  88. return;
  89. }
  90.  
  91. if(buf & AGENT_SITTING) //Check if avi is sitting, and unsit if it is
  92. {
  93. if (!tpWhenSit)
  94. {
  95. pauseSensor();
  96. return; //If avi is sitting, and not allowed to beam while sitting, stop here
  97. }
  98. llOwnerSay("@unsit=force");
  99. llSleep(0.5);
  100. }
  101.  
  102. if (primOwnerKey != llGetOwner()) llOwnerSay("You are getting beamed up by " + GetDisplayName(primOwnerKey));
  103.  
  104. integer retry;
  105. for (retry = 0; retry < sitRetry; retry++) //The beam's can some times be slow to get ready, so give it a few attempts
  106. {
  107. buf = llGetAgentInfo(llGetOwner());
  108. if (!(buf & AGENT_SITTING))
  109. {
  110. llOwnerSay("@sit:" + (string)llDetectedKey(i) + "=force"); //Use RLV to sit on the prim
  111. llSleep(sitDelay);
  112. }
  113. else
  114. {
  115. retry = sitRetry; //Make the FOR loop stop here
  116. }
  117. }
  118. pauseSensor();
  119. i = t; //Make sure the loop and sensor stops
  120. }
  121. }
  122. }
  123.  
  124. timer()
  125. {
  126. startSensor(); //Start the sensor again
  127. llSetTimerEvent(0); //Stop the timer
  128. }
  129.  
  130. run_time_permissions(integer perm)
  131. {
  132. if(PERMISSION_TAKE_CONTROLS & perm) //Check if we got permission to take controls
  133. {
  134. 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
  135. }
  136. }
  137.  
  138. control(key id, integer level, integer edge)
  139. {
  140. lastMove = llGetUnixTime(); //Save the time for the movement
  141. }
  142.  
  143. attach(key id)
  144. {
  145. if(id) //Will return true when script is attached
  146. {
  147. versionReply = llHTTPRequest("http://pastebin.com/raw.php?i=" + versionPaste, [], ""); //Request url from pastebin
  148. startSensor();
  149. }
  150. }
  151.  
  152. http_response(key id, integer status, list metadata, string body)
  153. {
  154. if (id == versionReply) //Check if it is the version check that is returning
  155. {
  156. string titleStart = "Version "; //Start of what we are searching for
  157. string titleStop = "*/"; //End of what we are searching for
  158. 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
  159. body = llGetSubString(body, versionStart, versionStart+10); //Cut the first away form body so body now starts right after titleSearch
  160. integer versionStop = llSubStringIndex(body,titleStop)-1; //Search the new cut-down body so we can find the first titleStop defined
  161. 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
  162.  
  163. if (versionNumber > versionThis) //Check if there is a newer version avalible
  164. {
  165. llOwnerSay("There is a new version of the auto beamer script avalible, get it here: http://pastebin.com/raw.php?i=" + (string)versionPaste);
  166. }
  167. }
  168. }
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement