SHARE
TWEET

simulation hud

a guest Feb 17th, 2019 215 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. simulation hud start
  2.  
  3. affiliate configurable script
  4.  
  5. list names = ["Hunger","Thirst","Bladder","Hygiene","Entertainment","Energy","Health","Fitness"];
  6. list stats = [0,0,0,0,0,0,0,0];
  7. /*change these numbers below to have an effect on the users meter where anything over 1 is adding anything in the negatives is taking away*/
  8. integer hunger = 1;
  9. integer thirst = 1;
  10. integer bladder = -1;
  11. integer hygiene = -1;
  12. integer entertainment = -1;
  13. integer energy = 0;
  14. integer health = 0;
  15. integer fitness = -1;
  16. default
  17. {
  18.     state_entry()
  19.     {
  20.         llResetOtherScript("petprojectapi");
  21.         stats = [hunger,thirst,bladder,hygiene,entertainment,energy,health,fitness];
  22.         integer i = 0;
  23.         for(i=0;i<llGetListLength(stats);++i)
  24.         {
  25.             llMessageLinked(LINK_SET,123,llList2String(names,i),llList2String(stats,i));
  26.         }
  27.         llMessageLinked(LINK_SET,123,"Config","");
  28.         //comment out the timer call if you dont want the item to be used automatically
  29.         //llSetTimerEvent(180.0);
  30.     }
  31.     timer()
  32.     {
  33.         llMessageLinked(LINK_SET,123,"TRIGGER",llGetOwner());
  34.     }
  35.     touch_start(integer total_number)
  36.     {
  37.         //comment out this line if you dont want to use rez and touch to trigger your item
  38.         llMessageLinked(LINK_SET,123,"TRIGGER",llDetectedKey(0));
  39.     }
  40. }
  41.  
  42.  
  43.  
  44. main api script
  45.  
  46.  
  47. string ProtocolSignature = "nolife"; // your own signature
  48. float ProtocolVersion = 0.1; // can range from 0.0 to 255.255
  49. string Password = "nolifeiscool"; // change this to your own password
  50. string Header;
  51. string strHex = "0123456789ABCDEF";
  52. string hex(integer value)
  53. {
  54.     integer digit = value & 0xF;
  55.     string text = llGetSubString(strHex, digit, digit);
  56.     value = (value >> 4) & 0xfffFFFF;
  57.     integer odd = TRUE;
  58.     while(value)
  59.     {
  60.         digit = value & 0xF;
  61.         text = llGetSubString(strHex, digit, digit) + text;
  62.         odd = !odd;
  63.         value = value >> 4;
  64.     }
  65.     if(odd)
  66.         text = "0" + text;
  67.     return text;
  68. }
  69. integer Debug = 0;
  70. string error(string message)
  71. {
  72.     if(Debug) llSay(DEBUG_CHANNEL, message);
  73.     return "";
  74. }
  75. string decrypt(string password, string message)
  76. {
  77.     integer signatureLength = llStringLength(ProtocolSignature);
  78.     integer headerLength = signatureLength + 12; // version = 4, nonce = 8
  79.  
  80.     // verify length of encrypted message
  81.     if(llStringLength(message) < signatureLength + 44) // digest = 32 (base64 = 44) + at least one character
  82.         return error("Too small for secret message.");
  83.  
  84.     // look for protocol signature in message header
  85.     if(llSubStringIndex(message, ProtocolSignature) != 0)
  86.         return error("Unknown protocol.");
  87.  
  88.     // Parse version information from header
  89.     integer index = signatureLength; // determine where to start parsing
  90.     string major = "0x" + llGetSubString(message, index, ++index);
  91.     string minor = "0x" + llGetSubString(message, ++index, ++index);
  92.     float version = (float)((string)((integer)major) + "." + (string)((integer)minor));
  93.  
  94.     // verify version is supported
  95.     if(version != ProtocolVersion)
  96.         return error("Unknown version.");
  97.  
  98.     // parse nonce from header
  99.     integer nonce = (integer)("0x" + llGetSubString(message, ++index, index + 7));
  100.  
  101.     // remove header from message
  102.     message = llGetSubString(message, headerLength, -1);
  103.  
  104.     // create one time pad from password and nonce
  105.     string oneTimePad = llMD5String(password, nonce);
  106.     // append pad until length matches or exceeds message
  107.     while(llStringLength(oneTimePad) < (llStringLength(message) / 2 * 3))
  108.         oneTimePad += llMD5String(oneTimePad, nonce);
  109.  
  110.     // decrypt message
  111.     oneTimePad = llStringToBase64(oneTimePad);
  112.     message = llXorBase64StringsCorrect(message, oneTimePad);
  113.  
  114.     // decode message
  115.     message = llBase64ToString(message);
  116.  
  117.     // get digest
  118.     string digest = llGetSubString(message, 0, 31);
  119.  
  120.     // remove digest from message
  121.     message = llGetSubString(message, 32, -1);
  122.  
  123.     // verify digest is valid
  124.     if(llMD5String(message, nonce) != digest)
  125.         return error("Message digest was not valid.");
  126.  
  127.     // return decrypted message
  128.     return message;
  129. }
  130. string encrypt(string password, string message)
  131. {
  132.     // get a random value
  133.     integer nonce = (integer)llFrand(0x7FFFFFFF);
  134.  
  135.     // generate digest and prepend it to message
  136.     message = llMD5String(message, nonce) + message;
  137.  
  138.     // generate one time pad
  139.     string oneTimePad = llMD5String(password, nonce);
  140.  
  141.     // append pad until length matches or exceeds message
  142.     integer count = (llStringLength(message) - 1) / 32;
  143.     if(count)
  144.         do
  145.             oneTimePad += llMD5String(oneTimePad, nonce);
  146.         while(--count);
  147.  
  148.     // return the header, nonce and encrypted message
  149.     return Header + llGetSubString("00000000" + hex(nonce), -8, -1) + llXorBase64StringsCorrect(llStringToBase64(message), llStringToBase64(oneTimePad));
  150. }
  151. init()
  152. {
  153.     //build the header, it never changes.
  154.     list versions = llParseString2List((string)ProtocolVersion, ["."], []);
  155.     string minor = llList2String(versions, 1);
  156.     integer p = 0;
  157.     while(llGetSubString(minor, --p, p) == "0");
  158.     Header = ProtocolSignature + hex(llList2Integer(versions, 0)) + hex((integer)llGetSubString(minor, 0xFF000000, p));    
  159. }
  160. list names = ["Hunger ","Thirst ","Bladder ","Hygiene ","Entertainment ","Energy ","Health ","Fitness "];
  161. list stats = [0,0,0,0,0,0,0,0];
  162. integer hunger;
  163. integer thirst;
  164. integer bladder;
  165. integer hygiene;
  166. integer entertainment;
  167. integer energy;
  168. integer health;
  169. integer fitness;
  170. integer apichan;
  171. integer apilis;
  172. integer appint = 123;
  173. integer Key2AppChan(key ID, integer App) {
  174.     return 0x80000000 | ((integer)("0x"+(string)ID) ^ App);
  175. }
  176. default
  177. {
  178.     state_entry()
  179.     {
  180.         apichan = Key2AppChan(llGetOwner(),appint);
  181.         init();
  182.     }
  183.     link_message(integer s,integer r,string str,key id)
  184.     {
  185.         if(str=="Hunger")
  186.         {
  187.             hunger = (integer)((string)id);
  188.         }else if(str=="Thirst")
  189.         {
  190.             thirst = (integer)((string)id);
  191.         }else if(str=="Bladder")
  192.         {
  193.             bladder = (integer)((string)id);
  194.         }else if(str=="Hygiene")
  195.         {
  196.             hygiene = (integer)((string)id);
  197.         }else if(str=="Entertainment")
  198.         {
  199.             entertainment = (integer)((string)id);
  200.         }else if(str=="Energy")
  201.         {
  202.             energy = (integer)((string)id);
  203.         }else if(str=="Health")
  204.         {
  205.             health = (integer)((string)id);
  206.         }else if(str=="Fitness")
  207.         {
  208.             fitness = 0;
  209.         }else if(str == "Config")
  210.         {
  211.             stats = [hunger,thirst,bladder,hygiene,entertainment,energy,health,fitness];
  212.             state run;
  213.         }
  214.     }
  215. }
  216. state run
  217. {
  218.     link_message(integer s,integer r,string str,key id)
  219.     {
  220.         if(str == "TRIGGER")
  221.         {
  222.             apichan = Key2AppChan(id,appint);
  223.             llSay(apichan,encrypt(Password,"nolife^FXSTATS^"+llDumpList2String(stats,"^")));
  224.         }
  225.     }
  226. }
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234. hud script meter thingy
  235.  
  236. string ProtocolSignature = "nolife"; // your own signature
  237. float ProtocolVersion = 0.1; // can range from 0.0 to 255.255
  238. string Password = "nolifeiscool"; // change this to your own password
  239. string Header;
  240. string strHex = "0123456789ABCDEF";
  241. string hex(integer value)
  242. {
  243.     integer digit = value & 0xF;
  244.     string text = llGetSubString(strHex, digit, digit);
  245.     value = (value >> 4) & 0xfffFFFF;
  246.     integer odd = TRUE;
  247.     while(value)
  248.     {
  249.         digit = value & 0xF;
  250.         text = llGetSubString(strHex, digit, digit) + text;
  251.         odd = !odd;
  252.         value = value >> 4;
  253.     }
  254.     if(odd)
  255.         text = "0" + text;
  256.     return text;
  257. }
  258. integer Debug = 0;
  259. string error(string message)
  260. {
  261.     if(Debug) llSay(DEBUG_CHANNEL, message);
  262.     return "";
  263. }
  264. string decrypt(string password, string message)
  265. {
  266.     integer signatureLength = llStringLength(ProtocolSignature);
  267.     integer headerLength = signatureLength + 12; // version = 4, nonce = 8
  268.  
  269.     // verify length of encrypted message
  270.     if(llStringLength(message) < signatureLength + 44) // digest = 32 (base64 = 44) + at least one character
  271.         return error("Too small for secret message.");
  272.  
  273.     // look for protocol signature in message header
  274.     if(llSubStringIndex(message, ProtocolSignature) != 0)
  275.         return error("Unknown protocol.");
  276.  
  277.     // Parse version information from header
  278.     integer index = signatureLength; // determine where to start parsing
  279.     string major = "0x" + llGetSubString(message, index, ++index);
  280.     string minor = "0x" + llGetSubString(message, ++index, ++index);
  281.     float version = (float)((string)((integer)major) + "." + (string)((integer)minor));
  282.  
  283.     // verify version is supported
  284.     if(version != ProtocolVersion)
  285.         return error("Unknown version.");
  286.  
  287.     // parse nonce from header
  288.     integer nonce = (integer)("0x" + llGetSubString(message, ++index, index + 7));
  289.  
  290.     // remove header from message
  291.     message = llGetSubString(message, headerLength, -1);
  292.  
  293.     // create one time pad from password and nonce
  294.     string oneTimePad = llMD5String(password, nonce);
  295.     // append pad until length matches or exceeds message
  296.     while(llStringLength(oneTimePad) < (llStringLength(message) / 2 * 3))
  297.         oneTimePad += llMD5String(oneTimePad, nonce);
  298.  
  299.     // decrypt message
  300.     oneTimePad = llStringToBase64(oneTimePad);
  301.     message = llXorBase64StringsCorrect(message, oneTimePad);
  302.  
  303.     // decode message
  304.     message = llBase64ToString(message);
  305.  
  306.     // get digest
  307.     string digest = llGetSubString(message, 0, 31);
  308.  
  309.     // remove digest from message
  310.     message = llGetSubString(message, 32, -1);
  311.  
  312.     // verify digest is valid
  313.     if(llMD5String(message, nonce) != digest)
  314.         return error("Message digest was not valid.");
  315.  
  316.     // return decrypted message
  317.     return message;
  318. }
  319. string encrypt(string password, string message)
  320. {
  321.     // get a random value
  322.     integer nonce = (integer)llFrand(0x7FFFFFFF);
  323.  
  324.     // generate digest and prepend it to message
  325.     message = llMD5String(message, nonce) + message;
  326.  
  327.     // generate one time pad
  328.     string oneTimePad = llMD5String(password, nonce);
  329.  
  330.     // append pad until length matches or exceeds message
  331.     integer count = (llStringLength(message) - 1) / 32;
  332.     if(count)
  333.         do
  334.             oneTimePad += llMD5String(oneTimePad, nonce);
  335.         while(--count);
  336.  
  337.     // return the header, nonce and encrypted message
  338.     return Header + llGetSubString("00000000" + hex(nonce), -8, -1) + llXorBase64StringsCorrect(llStringToBase64(message), llStringToBase64(oneTimePad));
  339. }
  340. init()
  341. {
  342.     //build the header, it never changes.
  343.     list versions = llParseString2List((string)ProtocolVersion, ["."], []);
  344.     string minor = llList2String(versions, 1);
  345.     integer p = 0;
  346.     while(llGetSubString(minor, --p, p) == "0");
  347.     Header = ProtocolSignature + hex(llList2Integer(versions, 0)) + hex((integer)llGetSubString(minor, 0xFF000000, p));    
  348. }
  349. list names = ["Hunger ","Thirst ","Bladder ","Hygiene ","Entertainment ","Energy ","Health ","Fitness "];
  350. list stats = [100,100,100,100,100,100,100,0];
  351. integer showtext = 1;
  352. integer fitnesstick = 0;
  353. text()
  354. {
  355.     if(showtext)
  356.     {
  357.         string out = "";
  358.         integer i = 0;
  359.         for(i=0;i<llGetListLength(stats);i++)
  360.         {
  361.             out += llList2String(names,i)+" "+llList2String(stats,i)+"%\n";
  362.         }
  363.         llSetText(out,<1,1,1>,1);
  364.     }else
  365.     {
  366.         llSetText("",<1,1,1>,1);
  367.     }
  368. }
  369. integer apichan;
  370. integer apilis;
  371. integer appint = 123;
  372. integer Key2AppChan(key ID, integer App) {
  373.     return 0x80000000 | ((integer)("0x"+(string)ID) ^ App);
  374. }
  375. integer tick = 0;
  376. dotimechange()
  377. {
  378.     integer curhunger = (integer)llList2String(stats,0);
  379.     integer curthirst = (integer)llList2String(stats,1);
  380.     integer curbladder = (integer)llList2String(stats,2);
  381.     integer curhygiene = (integer)llList2String(stats,3);
  382.     integer curentertainment = (integer)llList2String(stats,4);
  383.     integer curenergy = (integer)llList2String(stats,5);
  384.     integer curhealth = (integer)llList2String(stats,6);
  385.     integer curfitness = (integer)llList2String(stats,7);
  386.    
  387.     curhunger--;
  388.     if(curhunger<0)curhunger=0;
  389.     curthirst--;
  390.     if(curthirst<0)curthirst=0;
  391.     curbladder--;
  392.     if(curbladder<0)curbladder=0;
  393.     curhygiene--;
  394.     if(curhygiene<0)curhygiene=0;
  395.     curentertainment--;
  396.     if(curentertainment<0)curentertainment=0;
  397.     curenergy--;
  398.     if(curenergy<0)curenergy=0;
  399.    
  400.     if(fitnesstick>=100)
  401.     {
  402.         curfitness++;
  403.         if(curfitness>100)curfitness=100;
  404.     }else
  405.     {
  406.         curfitness--;
  407.         if(curfitness<-100)curfitness=-100;
  408.     }
  409.     stats = [curhunger,curthirst,curbladder,curhygiene,curentertainment,curenergy,curhealth,curfitness];
  410. }
  411. default
  412. {
  413.     on_rez(integer sp)
  414.     {
  415.         llResetScript();
  416.     }
  417.     state_entry()
  418.     {
  419.         init();
  420.         llListenRemove(apilis);
  421.         apichan = Key2AppChan(llGetOwner(),appint);
  422.         apilis = llListen(apichan,"","","");
  423.         if(llGetObjectDesc()!="NEWPLAYER")
  424.         {
  425.             string data = decrypt(Password, llGetObjectDesc());
  426.             stats = llParseString2List(data,["^"],[]);
  427.         }else
  428.         {
  429.             stats = [100,100,100,100,100,100,100,0];
  430.             llSetObjectDesc(encrypt(Password,llDumpList2String(stats,"^")));
  431.         }
  432.         text();
  433.         llSetTimerEvent(60);
  434.     }
  435.     listen(integer c,string n,key id,string m)
  436.     {
  437.         //llOwnerSay(m);
  438.         list t = llParseString2List(decrypt(Password,m),["^"],[]);
  439.         if(llList2String(t,0)=="nolife")
  440.         {
  441.             //llOwnerSay(llDumpList2String(t,","));
  442.             if(llList2String(t,1)=="FXSTATS")
  443.             {
  444.                 integer fxhunger = (integer)llList2String(t,2);
  445.                 integer fxthirst = (integer)llList2String(t,3);
  446.                 integer fxbladder = (integer)llList2String(t,4);
  447.                 integer fxhygiene = (integer)llList2String(t,5);
  448.                 integer fxentertainment = (integer)llList2String(t,6);
  449.                 integer fxenergy = (integer)llList2String(t,7);
  450.                 integer fxhealth = (integer)llList2String(t,8);
  451.                 integer fxfitness = (integer)llList2String(t,9);
  452.                
  453.                 integer curhunger = (integer)llList2String(stats,0);
  454.                 integer curthirst = (integer)llList2String(stats,1);
  455.                 integer curbladder = (integer)llList2String(stats,2);
  456.                 integer curhygiene = (integer)llList2String(stats,3);
  457.                 integer curentertainment = (integer)llList2String(stats,4);
  458.                 integer curenergy = (integer)llList2String(stats,5);
  459.                 integer curhealth = (integer)llList2String(stats,6);
  460.                 integer curfitness = (integer)llList2String(stats,7);
  461.                
  462.                 curhunger = curhunger+fxhunger;
  463.                 if(curhunger>100)curhunger=100;
  464.                 curthirst = curthirst+fxthirst;
  465.                 if(curthirst>100)curthirst=100;
  466.                 curbladder = curbladder+fxbladder;
  467.                 if(curbladder>100)curbladder=100;
  468.                 curhygiene = curhygiene+fxhygiene;
  469.                 if(curhygiene>100)curhygiene=100;
  470.                 curentertainment = curentertainment+fxentertainment;
  471.                 if(curentertainment>100)curentertainment=100;
  472.                 curenergy = curenergy+fxenergy;
  473.                 if(curenergy>100)curenergy=100;
  474.                 curhealth = curhealth+fxhealth;
  475.                 if(curhealth>100)curhealth=100;
  476.                 curfitness = curfitness+fxfitness;
  477.                 if(curfitness>100)curfitness=100;
  478.                
  479.                 stats = [curhunger,curthirst,curbladder,curhygiene,curentertainment,curenergy,curhealth,curfitness];
  480.                 text();
  481.                 llSetObjectDesc(encrypt(Password,llDumpList2String(stats,"^")));
  482.             }
  483.         }
  484.     }
  485.     timer()
  486.     {
  487.         integer curfitness = (integer)llList2String(stats,7);
  488.         tick++;
  489.         if(curfitness <= 10 && tick >=3)
  490.         {
  491.             tick=0;
  492.             dotimechange();
  493.         }else if((curfitness > 10 && curfitness <= 30) && tick >=10)
  494.         {
  495.             tick=0;
  496.             dotimechange();
  497.         }else if((curfitness > 30 && curfitness <= 70) && tick >=20)
  498.         {
  499.             tick=0;
  500.             dotimechange();
  501.         }else if((curfitness > 70) && tick >=25)
  502.         {
  503.             tick=0;
  504.             dotimechange();
  505.         }
  506.         integer buf = llGetAgentInfo(llGetOwner());
  507.         if(buf & AGENT_FLYING)
  508.         {
  509.             fitnesstick++;
  510.         }else
  511.         {
  512.             fitnesstick--;
  513.         }
  514.         if(buf & AGENT_WALKING)
  515.         {
  516.             fitnesstick++;
  517.         }else
  518.         {
  519.             fitnesstick--;
  520.         }
  521.         text();
  522.         llSetObjectDesc(encrypt(Password,llDumpList2String(stats,"^")));
  523.     }
  524. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top