SHARE
TWEET

NTAPSU Personal Always-On Charger [LSL]

N3K0 May 19th, 2017 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //------------------------------------------------------------------------------
  2. // MOTO'S MAINLAND EXPLORER ALWAYS-ON PERSONAL CHARGER FOR NTAPSU. [61 LINES.]
  3. //------------------------------------------------------------------------------
  4. // o Created   2017-05-19
  5. // o Modified  2017-05-19
  6. //------------------------------------------------------------------------------
  7. integer chan   = -0x6e336b302d32;// NTAPSU system channel.
  8. integer charge = 800;            // Charge applied to current PSU.
  9.  
  10. QueryPSU(){
  11.     psu=NULL_KEY;
  12.     llRegionSay(chan,"ohai? "+(string)llGetOwner()+"");
  13. }
  14.  
  15. Listen(integer on){
  16.     llListenRemove(lh);lh=-1;
  17.     if(on){lh=llListen(chan,"",NULL_KEY,"");}
  18. }
  19.  
  20. integer lh=-1;
  21. key     psu=NULL_KEY;
  22.  
  23. default {
  24.     state_entry() {
  25.         llRegionSayTo(llGetOwner(),chan,"connect 0");
  26.         llOwnerSay("ZPM inactive.");state np;
  27.     }
  28. }
  29.  
  30. state np {
  31.     attach(key k){
  32.         llResetScript();
  33.     }
  34.     timer(){
  35.         Listen(1);QueryPSU();
  36.     }
  37.     state_entry(){
  38.         QueryPSU();llSetTimerEvent(2.0);
  39.     }
  40.     listen(integer c,string n,key k,string m){
  41.         list w=llParseString2List(m,[" "],[]);
  42.         string c=llList2String(w,0);
  43.         string ke=llList2String(w,1);
  44.         if(c=="ohai!"){
  45.             if (ke==(string)llGetOwner()){psu=k;state p;}
  46.         }
  47.         w=[];
  48.     }
  49. }
  50.  
  51. state p {
  52.     timer(){
  53.         if(llKey2Name(psu)==""){llResetScript();}
  54.     }
  55.     attach(key k){
  56.         llResetScript();
  57.     }
  58.     state_entry(){
  59.         llOwnerSay("ZPM is ACTIVE.");
  60.         llRegionSayTo(psu,chan,"connect 1 "+(string)charge);llSetTimerEvent(5);
  61.     }
  62. }
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top