Advertisement
Guest User

Untitled

a guest
May 29th, 2014
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This script was made by Chakat Northspring (PanteraPolnocy Resident, 5e9cbbb8-1aef-4692-bfc4-a53f8c8fcbc9)
  2. // Script template version used: 1.2
  3.  
  4. key gOwnerKey;
  5. string gOwnerName;
  6. integer gDialogChannel;
  7. integer gListenHandle;
  8.  
  9. key gNotecardQueryId;
  10. integer gNotecardLine;
  11. string gNotecardName = "config";
  12.  
  13. string gAnimationName = "animation";
  14.  
  15. // Some handy functions, unused may be deleted
  16.  
  17. // Get a random list element
  18. string getRandomListElement(list elements)
  19. {
  20.     return llList2String(llListRandomize(elements, 0), 0);
  21. }
  22.  
  23. // Check if item is on list- change 'string' to any other data type you need
  24. integer isOnList(list testList, string testItem)
  25. {
  26.     if (~llListFindList(testList, (list)testItem))
  27.     {
  28.         return TRUE;
  29.     }
  30.     else
  31.     {
  32.         return FALSE;
  33.     }
  34. }
  35.  
  36. // Rotations translation
  37. rotation vector2rot(vector calrot)
  38. {
  39.     return llEuler2Rot(calrot * DEG_TO_RAD); // Quron Dagger's one, after modification
  40. }
  41.  
  42. vector rot2vector(rotation calrot)
  43. {
  44.     return RAD_TO_DEG * llRot2Euler(calrot);
  45. }
  46.  
  47. // Colors translation
  48. vector lsl2rgb(vector values)
  49. {
  50.     values *= 255;
  51.     return <(integer)values.x, (integer)values.y, (integer)values.z>;
  52. }
  53.  
  54. vector rgb2lsl(vector values)
  55. {
  56.     return values / 255;
  57. }
  58.  
  59. // Long range prim moving, change LINK_THIS to LINK_ROOT if needed
  60. longRangemoveToPos(vector position)
  61. {
  62.     while (llList2Vector(llGetLinkPrimitiveParams(LINK_THIS, [PRIM_POSITION]), 0) != position)
  63.     {
  64.         llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, position]);
  65.     }
  66. }
  67.  
  68. // Using no_sensor() as second llSetTimerEvent()
  69. setTimerEvent2(float time)
  70. {
  71.     if (time <= 0)
  72.     {
  73.         llSensorRemove();
  74.     }
  75.     else if (time < 0.5)
  76.     {
  77.         llOwnerSay("For performance reasons you can't set setTimerEvent2() value < than 0.5");
  78.     }
  79.     else
  80.     {
  81.         llSensorRepeat("cake is a lie", NULL_KEY, AGENT_BY_LEGACY_NAME, 0.001, 0.001, time);
  82.     }
  83. }
  84.  
  85. // Script starts here
  86. default
  87. {
  88.  
  89.     state_entry()
  90.     {
  91.  
  92.         // Populating often used variables
  93.         gOwnerKey = llGetOwner();
  94.         gOwnerName = llGetDisplayName(gOwnerKey) + " (" + llKey2Name(gOwnerKey) + ")";
  95.         gDialogChannel = (integer)(llFrand(-1000000000)-1000000000);
  96.  
  97.         // Notecard reader here
  98.         if (llGetInventoryKey(gNotecardName) == NULL_KEY)
  99.         {
  100.             llOwnerSay("Notecard '" + gNotecardName + "' missing or unwritten.");
  101.         }
  102.         else
  103.         {
  104.             gNotecardQueryId = llGetNotecardLine(gNotecardName, 0);
  105.         }
  106.  
  107.         // Some memory management here, with mininum 20KB buffer
  108.         // Note: if notecard reading system will be used, then this should be moved to the end of 'if (data == EOF)' section in 'dataserver' event, right before 'return;'
  109.         integer usedMemory = llGetUsedMemory();
  110.         if (usedMemory < 45056)
  111.         {
  112.             llSetMemoryLimit(usedMemory + 20480);
  113.         }
  114.  
  115.         // Work: non-script zones. See run_time_permissions().
  116.         // If no animation is used in script feel free to replace '(PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION)' with 'PERMISSION_TAKE_CONTROLS'
  117.         if (llGetAttached() != 0)
  118.         {
  119.             llRequestPermissions(gOwnerKey, (PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION));
  120.         }
  121.  
  122.     }
  123.  
  124.     listen(integer channel, string name, key id, string message)
  125.     {
  126.  
  127.         // This shouldn't happen, if listener is set to a fixed channel anyway
  128.         // Feel free to remove it, if you're using only one channel
  129.         if (channel != gDialogChannel)
  130.         {
  131.             return;
  132.         }
  133.  
  134.         llOwnerSay(message);
  135.         llSetTimerEvent(2); // Speed up time, so llListenRemove() can be called
  136.  
  137.     }
  138.  
  139.     touch_start(integer total_number)
  140.     {
  141.         gListenHandle = llListen(gDialogChannel, "", gOwnerKey, "");
  142.         llDialog(gOwnerKey, "\nMew.", ["Mew", "Purr", "Cookies"], gDialogChannel);
  143.         llSetTimerEvent(60);
  144.     }
  145.  
  146.     timer()
  147.     {
  148.         llListenRemove(gListenHandle); // Save some CPU/memory, if channel is not used for some time
  149.         llSetTimerEvent(0);
  150.     }
  151.  
  152.     on_rez(integer sp)
  153.     {
  154.         llResetScript();
  155.     }
  156.  
  157.     dataserver(key request_id, string data)
  158.     {
  159.         if (request_id == gNotecardQueryId)
  160.         {
  161.             if (data == EOF)
  162.             {
  163.                 llOwnerSay("Notecard read, " + (string)gNotecardLine + " lines.");
  164.                 return;
  165.             }
  166.             else if (data != "")
  167.             {
  168.                 llOwnerSay("Notecard line: " + data);
  169.             }
  170.             gNotecardQueryId = llGetNotecardLine(gNotecardName, ++gNotecardLine);
  171.         }
  172.     }
  173.  
  174.     changed(integer change)
  175.     {
  176.         if (change & (CHANGED_OWNER | CHANGED_INVENTORY | CHANGED_ALLOWED_DROP))
  177.         {
  178.             llResetScript();
  179.         }
  180.         else if (change & CHANGED_LINK)
  181.         {
  182.             key avatarKey = llAvatarOnLinkSitTarget(LINK_THIS);
  183.             if (avatarKey)
  184.             {
  185.                 llRequestPermissions(avatarKey, (PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION));
  186.             }
  187.         }
  188.     }
  189.  
  190.     attach(key avatarKey)
  191.     {
  192.         if (avatarKey)
  193.         {
  194.             llRequestPermissions(avatarKey, (PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION));
  195.         }
  196.         else
  197.         {
  198.             llStopAnimation(gAnimationName);
  199.         }
  200.     }
  201.  
  202.     run_time_permissions(integer perm)
  203.     {
  204.         if (perm & PERMISSION_TRIGGER_ANIMATION)
  205.         {
  206.             llStartAnimation(gAnimationName);
  207.         }
  208.         if (perm & PERMISSION_TAKE_CONTROLS)
  209.         {
  210.             // Take control for value that does nothing, in order to work in no-script sims
  211.             llTakeControls(1024, TRUE, TRUE);
  212.         }
  213.     }
  214.  
  215.     no_sensor()
  216.     {
  217.         // If there is no sensor event in script itself, then setTimerEvent2() function becomes available
  218.         // no_sensor() is used as a second timer(), because lightweight llSensorRepeat() query is using impossible to meet requirements
  219.         llOwnerSay("Timer event 2");
  220.     }
  221.  
  222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement