Author: Not specified Language: cpp
Description: Not specified Timestamp: 2013-05-16 15:06:11 +0000
View raw paste Reply
  1. list standingAnimations = [
  2.    
  3. ];
  4.  
  5. list standardSittingAnimations = [
  6.    
  7. ];
  8.  
  9. list groundSittingAnimations = [
  10.    
  11. ];
  12.  
  13. list walkingAnimations = [
  14.    
  15. ];
  16.  
  17. list runningAnimations = [
  18.    
  19. ];
  20.  
  21. list standardAnimations = [
  22.     "D1207-Crouch (Teen)", // "Crouching",
  23.     "D1138-Walk.C (Teen)", // "CrouchWalking",
  24.     "dz660-Falling", // "Falling Down",
  25.     "D2296-Fly.N", // "Flying",
  26.     "D2296-Fly.N", // "FlyingSlow",
  27.     "D2298-Hover.N", // "Hovering",
  28.     "", // "Hovering Down",
  29.     "D2300-Hover.U", // "Hovering Up",
  30.     "dz564-Jump.N", // "Jumping",
  31.     "D0664-Land.N (Teen)", // "Landing",
  32.     "D1210-Jump.P (Teen)", // "PreJumping",
  33.     "dz520-Running", // "Running",
  34.     "", // "Standing Up",
  35.     "", // "Striding",
  36.     "D0664-Land.N (Teen)", // "Soft Landing",
  37.     "", // "Taking Off",
  38.     "D0731-Turn.L", // "Turning Left",
  39.     "D0730-Turn.R"  // "Turning Right"
  40. ];
  41.  
  42. string typingAnimation = "";
  43.  
  44. list advancedStates = [
  45.     "Standing",
  46.     "Sitting",
  47.     "Sitting on Ground",
  48.     "Walking",
  49.     "Running"
  50. ];
  51.  
  52. list standardStates = [
  53.     "Crouching",
  54.     "CrouchWalking",
  55.     "Falling Down",
  56.     "Flying",
  57.     "FlyingSlow",
  58.     "Hovering",
  59.     "Hovering Down",
  60.     "Hovering Up",
  61.     "Jumping",
  62.     "Landing",
  63.     "PreJumping",
  64.     "Running",
  65.     "Standing Up",
  66.     "Striding",
  67.     "Soft Landing",
  68.     "Taking Off",
  69.     "Turning Left",
  70.     "Turning Right"
  71. ];
  72.  
  73. key ownerKey;
  74.  
  75. debugMessage(string message)
  76. {
  77.     llSay(DEBUG_CHANNEL, llGetObjectName() + "[script:" + llGetScriptName() + "] " + message);
  78. }
  79.  
  80. initializePermissions()
  81. {
  82.     if (llGetPermissions() & PERMISSION_OVERRIDE_ANIMATIONS)
  83.     {
  84.         integer index  = 0;
  85.         integer states = llGetListLength(standardStates);
  86.  
  87.         if (states == llGetListLength(standardAnimations))
  88.         {
  89.             reloadStandardAnimations(states);
  90.         }
  91.         else
  92.         {
  93.             debugMessage("Sainty mismatch error, number of states to animations or vice versa");
  94.         }
  95.  
  96.         // setup advancedStates here.
  97.     }
  98.     else
  99.     {
  100.         ownerKey = llGetOwner();
  101.  
  102.         llRequestPermissions(ownerKey, PERMISSION_OVERRIDE_ANIMATIONS);
  103.     }
  104. }
  105.  
  106. reloadStandardAnimations(integer states)
  107. {
  108.     integer index  = 0;
  109.  
  110.     string animation;
  111.     string anim_state;
  112.     integer type;
  113.  
  114.     while (index < states)
  115.     {
  116.         animation = llList2String(standardAnimations, index);
  117.         anim_state = llList2String(standardStates, index);
  118.  
  119.         if (animation != "")
  120.         {
  121.             type = llGetInventoryType(animation);
  122.  
  123.             if (type == INVENTORY_ANIMATION)
  124.             {
  125.                 llSetAnimationOverride(anim_state, animation);
  126.             }
  127.             else if(type == INVENTORY_NONE)
  128.             {
  129.                 debugMessage(
  130.                     "Animation \"" + animation + "\" for state \"" + anim_state +
  131.                     "\" is missing or spelt incorrectly, remeber inventory items are case sensitive."
  132.                 );
  133.             }
  134.             else
  135.             {
  136.                 debugMessage(
  137.                     "Animation \"" + animation + "\" for state \"" + anim_state +
  138.                     "\" is of the incorrect inventory type."
  139.                 );
  140.             }
  141.         }
  142.  
  143.         ++index;
  144.     }
  145. }
  146.  
  147. default
  148. {
  149.     state_entry()
  150.     {
  151.         initializePermissions();
  152.     }
  153.  
  154.     attach(key id)
  155.     {
  156.         if (id)
  157.         {
  158.             // on_rez handles reinitializing.
  159.         }
  160.         else if (llGetPermissions() & PERMISSION_OVERRIDE_ANIMATIONS)
  161.         {
  162.             llResetAnimationOverride("ALL");
  163.         }
  164.     }
  165.  
  166.     on_rez(integer param)
  167.     {
  168.         initializePermissions();
  169.     }
  170.  
  171.     run_time_permissions(integer perms)
  172.     {
  173.         initializePermissions();
  174.     }
  175. }
  176.  
View raw paste Reply