Guest

Untitled

By: a guest on Aug 18th, 2011  |  syntax: None  |  size: 1.94 KB  |  hits: 102  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. // Get your NPCs (and whoever else may be in the region) to dance.
  2. // To make this work, create a prim, fill it with (dance) animations, put this script in it, click the prim, and PAR-TAY!.
  3.  
  4. list avies;
  5. list thedance;
  6. list olddance;
  7. list dancers;
  8. integer duration = 10;
  9.  
  10. EverybodyDanceNow()
  11. {
  12.     llSetText("Dancing",<1,1,1>,1);
  13.     avies = osGetAvatarList();
  14.     integer n;
  15.  
  16.     if(llGetListLength(thedance) != 0)
  17.     {
  18.         for(n=0;n<llGetListLength(thedance);++n)
  19.         {
  20.             olddance = olddance + llList2String(thedance,n);
  21.         }
  22.     }
  23.  
  24.  
  25.     for(n=0;n<llGetListLength(avies);n=n+3)
  26.     {
  27.         integer animnum = llFloor(llFrand(llGetInventoryNumber(INVENTORY_ANIMATION)));
  28.         string animation = llGetInventoryName(INVENTORY_ANIMATION,animnum);
  29.         key avieID = llList2Key(avies,n);
  30.         dancers = dancers + [avieID];
  31.         thedance = thedance + [animation];
  32.     }
  33.  
  34.     for(n=0;n<llGetListLength(dancers);++n)
  35.     {
  36.         key avie = llList2Key(dancers,n);
  37.         string dance = llList2String(thedance,n);
  38.         osAvatarPlayAnimation(avie, dance);
  39.  
  40.     }
  41. }
  42.  
  43. Stop_HammerTime()
  44. {
  45.     llSetText("Stopped Dancing",<1,1,1>,1);
  46.     integer n;
  47.     for(n=0;n<llGetListLength(dancers);++n)
  48.     {
  49.         key avie = llList2Key(dancers,n);
  50.         string dance = llList2String(thedance,n);
  51.         osAvatarStopAnimation(avie, dance);
  52.     }
  53.         dancers = [];
  54.         thedance = [];
  55.         avies = [];
  56. }
  57.  
  58. default
  59. {    
  60.     touch_start(integer numdet)
  61.     {
  62.         state on;
  63.     }
  64. }
  65.  
  66. state on
  67. {
  68.     state_entry()
  69.     {
  70.         EverybodyDanceNow();
  71.         llSetTimerEvent(duration);
  72.     }
  73.  
  74.     touch_start(integer numdet)
  75.     {
  76.         state off;
  77.     }
  78.  
  79.     timer()
  80.     {
  81.         EverybodyDanceNow();
  82.     }
  83. }
  84.  
  85.  
  86. state off
  87. {
  88.     state_entry()
  89.     {
  90.         Stop_HammerTime();
  91.     }
  92.  
  93.     touch_start(integer numdet)
  94.     {
  95.         state on;
  96.     }
  97. }