// Bromley College 
// Linden Script Exhibition
 
// Code for poster 36
 
// Note capital letters have been used for some variable names in this script purely for the sake of readability
 
integer CHANNEL = 42; // dialog channel
list MENU_MAIN = ["bow", "flip", "jump"]; // the main menu
string anim;
 
default 
{
    touch_start(integer total_number) //wait for an avatar to touch the poster
    {
        llSay(0, "Respond to the dialog box and then touch the poster again");
        llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION); //ask permission to animate the avatar that touched the poster
        state new; 
    }
}    
 
state new
{        
 
state_entry()     
    {
            llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users 
    }        
 
        touch_start(integer total_number) 
        {
        llDialog(llDetectedKey(0), "What animation do you want your avatar to perform?", MENU_MAIN, CHANNEL); // present dialog on click
    }
 
        listen(integer channel, string name, key id, string message) 
        {
            if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) //if animate permission has been given
            {
                    if (message == "jump")
                        {
                            anim = "jumpforjoy";
                        llStartAnimation(anim);
                            llSay(0,(string)anim);
                               llResetScript();
                    }
 
                    if (message == "flip")
                        {
                            anim = "backflip";
                        llStartAnimation(anim);
                            llSay(0,(string)anim);
                            llResetScript();
                    }
 
                    if (message == "bow")
                    {
                            anim = "courtbow";
                        llStartAnimation(anim);
                            llSay(0,(string)anim);
                            llResetScript();
                         }
                }
 
             if (! (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) //if animate permission has not been given
             {
                     llSay(0, "Agent has not given permission");
                      llResetScript();
            }    
    }     
}                                
 
// End of code;