Drink script

From Second Life Wiki
Jump to navigation Jump to search

A what?

A drink script, used in many parts of Second Life. Whether it's for food or drink, or roleplay potions and what-not, a drink script is always included. If it's not, it's rubbish.

Okay, okay, let's get this script, then

<lsl>//Emmas Seetan //1st November 2008 //21:59

integer flag = 0;


default {

   state_entry()
   {
       llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); //asks the owner's permission
   }
   run_time_permissions(integer parm)
   {
       if(parm & PERMISSION_TRIGGER_ANIMATION) //triggers animation
       {
           llSetTimerEvent(15); //how often it happens
           llStartAnimation("hold_R_handgun"); //animation to play
       }
   }
   on_rez(integer st)
   {
       llResetScript();
   }
   attach(key id)
   {
       if(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
           llStopAnimation("hold_R_handgun"); //stops when detached
   }
   timer()
   {
       if(flag & 1)
       {
           llStartAnimation("drink"); //starts animation
       }
       flag = (flag + 1) % 4;
   }

}</lsl>