Advertisement
plaguewolf

Untitled

Oct 10th, 2015
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. /*
  2. *
  3. * Scripts and prims are property of GwyUnder, or Gwyneth
  4. *
  5. * Utility collar Script v1.0
  6. */
  7.  
  8. // NOTES
  9. // use llLinkMessage instead of llListen to reduce overhead!
  10. //
  11. //
  12. //
  13. //
  14. //
  15. //////////////////////////////////////////////////////////////////////////////////////
  16.  
  17.  
  18. //defing common data sets
  19.  
  20. key ownerUUID;
  21. key ownerDisplayName;
  22. key ownerLName;
  23.  
  24. list cmd;
  25.  
  26. //define channel names
  27.  
  28. integer broadcastComms = 0;
  29. integer cmdComms = 7;
  30. integer debugComms;
  31.  
  32. //Comms handlers
  33.  
  34. integer broadcastHand;
  35. integer cmdHand;
  36. integer debugHand;
  37.  
  38.  
  39. //DEBUG state
  40.  
  41. //integer DEBUG = TRUE;
  42.  
  43. //setup the uuid2Channel funtion
  44.  
  45. integer uiKey2Range(key vkID, integer viBase, integer viRange)
  46. {
  47. // # Result will be added or subtracted dependent on viBase being positive or negative, for intuitive results.
  48. // > Example: -56000/1000 will result in -56000 to -56999, whereas 56000/1000 will result in 56000 to 56999
  49. integer viMult = 1;
  50. if( viBase < 0 ) { viMult = -1; }
  51. return (viBase+(viMult*(((integer)("0x"+(string)vkID)&0x7FFFFFFF)%viRange)));
  52. }
  53.  
  54. default
  55. {
  56.  
  57. //set things up when owner equips the item
  58. changed(integer change)
  59. {
  60. if (change & CHANGED_OWNER)
  61. {
  62. llResetScript();
  63. }
  64. }
  65.  
  66. on_rez(integer start_param)
  67. {
  68. llResetScript();
  69. }
  70.  
  71. state_entry()
  72. {
  73.  
  74. ownerUUID = (string)llGetOwner();
  75. ownerDisplayName = (string)llGetDisplayName(ownerUUID);
  76. ownerLName = (string)llKey2Name(ownerUUID);
  77.  
  78. debugComms = uiKey2Range(ownerUUID, -740000, 10000);
  79.  
  80. broadcastHand = llListen(broadcastComms, "", ownerUUID, "");
  81. cmdHand = llListen(cmdComms, "", ownerUUID, "");
  82. debugHand = llListen(debugComms, "", ownerUUID, "");
  83.  
  84. llOwnerSay("GwynTools :: Initializing...");
  85.  
  86. }
  87.  
  88.  
  89. //enter the listen state
  90.  
  91. listen(integer channel, string name, key ownerUUID, string message)
  92. {
  93.  
  94. llOwnerSay("LISTEN : initicialized!");
  95.  
  96. name = llToLower(llGetObjectName());
  97.  
  98. llOwnerSay("LISTEN : name!");
  99. llOwnerSay("LISTEN : Message = " + (string)channel + (string)name + (string)message);
  100.  
  101. //parse the relevant command and strip bad chars and spaces
  102.  
  103. if( llSubStringIndex(llToLower(message),name) != 0) return;
  104. message = llStringTrim(llGetSubString(message,llStringLength(name),-1),STRING_TRIM);
  105.  
  106.  
  107.  
  108. //string trim_msg = llStringTrim(message)
  109.  
  110.  
  111. llOwnerSay("LISTEN : trim!");
  112.  
  113. list params = llParseString2List(message,[" "],[]);
  114. string command = llToLower(llList2String(params,0));
  115. string param = llDumpList2String(llDeleteSubList(params,0,0)," ");
  116.  
  117. llOwnerSay("LISTEN : parse!");
  118.  
  119. /*
  120.  
  121. if ( command == "channel")
  122. {
  123. cmdComms = (integer)llList2String( cmd, 2);
  124. llListenRemove( cmdHand );
  125. cmdHand = llListen(cmdComms, "" , ownerUUID, "");
  126. llOwnerSay( "Listen Channel set to " + (string)cmdComms);
  127. }
  128. else
  129.  
  130. */
  131.  
  132.  
  133.  
  134.  
  135. if(channel == cmdComms)
  136. {
  137. //llListenRemove(cmdHand);
  138. llOwnerSay("LISTEN : channel cmdComms!");
  139.  
  140. if(command == "avatar" && message == "AVATAR")
  141. {
  142. llOwnerSay("Hello, Avatar!");
  143. }
  144. else if(command == "test")
  145. {
  146. llOwnerSay("This is a test!");
  147. }
  148.  
  149. }
  150.  
  151. }
  152.  
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement