Follow Script

Expired

// From Open Basic Follower/Facing Script, by Logan Bauer. //
///////////////////////////////////////////////////////////////////////
// OFFSET is the position of your pet in relation to it's owner's position.
// For example, in the default setting below, "vector offset =<-1,0,1>;"
// I.E. (x,y,z), the -1 puts it 1m back behind owner, the 0 means don't have
// it stay left or right, and 1 means have it stay 1m above it's owner.
// So, if you wanted the script to make it follow directly in front of you,
// and to the left, then you would change it to "vector offset =<1 ,1,0>;"


// llFrand(float max)

vector offset =<-1.2,0,1>;
vector currentoffset =<0,0,0>;
float xshift =.2; //How far it roams forward and back.
float yshift =1.25; //How wide it roams left to right.
float bob =2; //multiplyer of the BobCycle listed below.
float shifttime =5; //average time it takes to shift to another XY position.
integer timeset=0; //Is the timer running?
float currentxshift =0; //current X shift position
float currentyshift =0; //current Y shift position
float currentyfacing =0; //currentyfacing storage
integer currentbob; //current state of the BobCycle
float bobbing =0; //bob storage
list BobCycle = [0.0, 0.08, 0.12, 0.14, 0.15, 0.14, 0.12, 0.08, 0.0, -0.08, -0.12, -0.14, -0.15, -0.14, -0.12, -0.08];


startup()
{
vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_Z,TRUE);
llSetStatus(STATUS_PHYSICS, TRUE);
key id = llGetOwner();
llSensorRemove();
llSensorRepeat("",llGetOwner(),AGENT,200,2*PI,.5);
}

default
{
state_entry()
{
startup();


}

on_rez(integer start_param)
{
startup();
}

sensor(integer total_number)
{
vector pos = llDetectedPos(0);

bobbing = llList2Float(BobCycle, currentbob)*bob;

llSetTimerEvent(llFrand(shifttime));
currentoffset = ;
llMoveToTarget(pos+(offset+currentoffset)*llDetectedRot(0),.3);
if (currentyshift>=0)
{
currentyfacing = currentyshift;
} else {
currentyfacing = currentyshift*-1;
}

llLookAt(pos+<0,0+(currentyfacing*.33),1+bobbing>, 1 , 2);

currentbob = currentbob +1;
if (currentbob == 16)
{
currentbob = 0;
}

if(timeset==0)
{
timeset = 1;
llSetTimerEvent(((llFrand(shifttime)+llFrand(shifttime)+llFrand(shifttime))/3)*2);
}


}

timer()
{
timeset = 0;
currentyshift = llFrand(yshift*2)-yshift;
currentxshift = llFrand(xshift*2)-xshift;
}
}

 

Dance Script

Expired

list dances = [ "BackFlip","dance1", "dance2", "dance3", "dance4" ];
integer WHICH = 0;
integer TOTAL = 5;
integer PERMS = 0;
integer ON = FALSE;

default
{
    state_entry()
    {
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
        llSetTimerEvent(1.0);
        llListen(0, "", llGetOwner(), "");
    }

    timer()
    {
        PERMS = llGetPermissions();
        if (PERMS & PERMISSION_TRIGGER_ANIMATION)
        {
            if (ON == TRUE)
            {
                llStopAnimation(llList2String(dances, WHICH - 1));
                llStartAnimation(llList2String(dances, WHICH));
                WHICH++;
                if (WHICH >= TOTAL)
                {
                    WHICH = 0;
                }
            } else if (ON == 2)
            {
                llStopAnimation(llList2String(dances, WHICH - 1));
                WHICH = (integer)llFrand(TOTAL + 0.999);
                llStartAnimation(llList2String(dances, WHICH));
            }
        }
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if (channel == 0 && id == llGetOwner())
        {
            if (message == "doff")
            {
                ON = FALSE;
            } else if (ON == FALSE && message == "don")
            {
                if (!(PERMS & PERMISSION_TRIGGER_ANIMATION))
                {
                    llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
                }
                ON = TRUE;
            } else if (ON == FALSE && message == "dancer")
            {
                if (!(PERMS & PERMISSION_TRIGGER_ANIMATION))
                {
                    llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
                }
                ON = 2;
            }
        }
    }
}

 

Dance Pole Script

Expired

integer HIDE = FALSE; //If set to true, it will make the prim invisible when someone is on it (for use with poseballs)

integer CHANNEL; //channel for script to communicate on (generated radomly below)

vector Angle = <0,0,0>; 
string LoadText = "Ready"; 
string Context = "Dance";

integer LISTENER; //listener placeholder to kill active listens

key AVATAR; //this will be set to the person sitting on the prim

vector POS = <0.2,-0,-0.6>;//This is the initial sit target point.

list ANIM_MENU;
list REF_MENU;
integer COUNT = 1;
//---- Global variables are in all caps, local variables are all lowercase, do not try to use local variables out of context. ----//

Stop_All_Animations(key avatar) //this will be called below to stop the animations playing on an avatar, before animating them with your animations.
{
    list animations = llGetAnimationList(avatar);//Make a list of all the animations they are currently playing
    integer i;
    for(i = 0; i  12)
                {
                    name = llGetSubString(name, x - 10, x - 1);
                }
                REF_MENU += name;
            }
        }
    }
    else
    {
        ANIM_MENU = ["Previous", "Move Av", "Next"];  
        REF_MENU = ["Previous", "Move Av", "Next"];      
        integer start = (COUNT * 9) - 9;
        integer stop = (COUNT * 9) - 1;
        integer i;
        for(i = start; i <= stop; ++i)
        {
            string name = llGetInventoryName(INVENTORY_ANIMATION, i);
            if(name != "")
            {
                ANIM_MENU += name;
                integer x = llStringLength(name);
                if(x > 12)
                {
                    name = llGetSubString(name, x - 10, x - 1);
                }
                REF_MENU += name;
            }
        }
    }
    llSetTimerEvent(600); //Set up a timer to kill the listen if no response is received
    CHANNEL = (integer)llFrand((2147283648) + 100000) * -1; //pick a random negative channel to communicate on
    LISTENER = llListen(CHANNEL, "", llDetectedKey(0), "");//open  a listen
    llDialog(llAvatarOnSitTarget(), "Please choose an option", REF_MENU, CHANNEL);
}
    

default
{
    
    state_entry()//State entry occurs whenever a script is reset, or when you make changes and save it.
    {
        llSitTarget(POS, ZERO_ROTATION);//set the point where the person will sit. 
    }
    changed(integer change)//if something changed
    {
        if(change & CHANGED_LINK)//if the something was a link change (when an avatar sits on an object, they link to it)
        {
            if(llAvatarOnSitTarget() != NULL_KEY)//if someone is on me
            {
                AVATAR = llAvatarOnSitTarget();//Set the global variable to their key for use elsewhere.
                if(HIDE)//if the hide feature is set to true
                {
                    llSetAlpha(0.0, ALL_SIDES);//Make this prim invisible
                }
                llRequestPermissions(AVATAR, PERMISSION_TRIGGER_ANIMATION);//ask for permission to animate them (it's granted automatically if they are sitting on this, but still needs to be called for it to work.)
            }
            else//if something changed and noone is sitting on me
            {
                Stop_All_Animations(AVATAR);//call the stop all aniamtions function.
                llSetAlpha(1.0, ALL_SIDES);//make this prim visible
            }            
        }        
    }
    
    run_time_permissions(integer perm)//if we have permission to do something
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)//and that permisson is to animate them
        {
            Stop_All_Animations(AVATAR);//call the stop all aniamtions function.
            string animation = llGetInventoryName(INVENTORY_ANIMATION, 0);//find the first animation in my inventory
            llStartAnimation(animation);//animate them with it.
        }
    }
    
    touch_start(integer x)//when someone touches the object containing this script.
    {
        if(llDetectedKey(0) == llAvatarOnSitTarget()) //if the persosn touching this is sitting on the object
        {
            PresentMenu();
        }
    }
    
    timer()// If they ran out of time before making a selection.
    {
        llListenRemove(LISTENER); //remove the listener
        llSetTimerEvent(0); //set listen remove timer back to off
    }
        
    
    listen(integer ch, string name, key id, string msg)//When a response is received
    {
        llListenRemove(LISTENER); //remove the listener
        llSetTimerEvent(0); //set listen remove timer back to off
        if(msg == "Move Av")
        {
            llSetTimerEvent(600); //Set up a timer to kill the listen if no response is received
            LISTENER = llListen(9, "", id, "");//open  a listen
            llInstantMessage(id, "Please type the amount to move in this format  Front/Back, Left/Right, Up/Down   on channel 9. For example to move your avatar down 0.25m type  /9 0,0,-0.25");
            return;
        }
        else if(msg == "Next")
        {
            float MAX = llGetInventoryNumber(INVENTORY_ANIMATION);
            MAX = MAX / 9.0;
            integer MAXIMUM = llCeil(MAX);
            ++COUNT;
            if(COUNT > MAXIMUM)
            {
                COUNT = 1;
            }
            PresentMenu();
        }
        else if(msg == "Previous")
        {
            if(COUNT > 1)
            {
                --COUNT;
            }
            else
            {
                float MAX = llGetInventoryNumber(INVENTORY_TEXTURE);
                MAX = MAX / 10.0;
                integer MAXIMUM = llCeil(MAX);
                COUNT = MAXIMUM;
            }
            PresentMenu();
        }
        else if(ch == 9)
        {
            msg = "<"+msg+">";
            POS += (vector)msg;
            llSetLinkPrimitiveParams(2, [PRIM_POSITION, POS]);
            return;
        }
        else if(PERMISSION_TRIGGER_ANIMATION && id == llAvatarOnSitTarget())//if we have permisson is to animate them, and they are still sitting on this.
        {
            Stop_All_Animations(id);
            integer pos = llListFindList(REF_MENU, [msg]);
            msg = llList2String(ANIM_MENU, pos);
            llStartAnimation(msg);
        }
        else//if we don't have permission to animate them
        {
            if(llAvatarOnSitTarget() != NULL_KEY)//if someone is on me
            {
                llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);//request permission to animate them
            }
        }        
    }
}
// END //

 

Poser/Poseball Script

Expired


string sitAnimation = "A";
// if sitAnimation is left blank
// the script will grab the first animation in the container.
// if a value is set, it will use that instead.
//string sitAnimation = "yoga_float";


default {
    on_rez(integer start_param) {
        llResetScript();
    } 

    state_entry() {
        llSetText("Sit to Pose", <0.0,1.0,0.0>, 1);
        llSitTarget( <0,0,0.75>, ZERO_ROTATION );

        // if blank, we look in inventory
        if (sitAnimation == "") {
            sitAnimation = llGetInventoryName(INVENTORY_ANIMATION, 0);
            
            // oops, use default
            if (sitAnimation == "") {
                sitAnimation = "sit";
            }
        }
    }


    // Using state to control sitting
    // If you're in this state, no one is sitting
    changed(integer change) {
        if (change & CHANGED_LINK) {
            key avatar = llAvatarOnSitTarget();
            if ( avatar != NULL_KEY )  {
                llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
            }
        }        
    }

        
    run_time_permissions(integer parm) {
        if(parm == PERMISSION_TRIGGER_ANIMATION) {
            llStopAnimation("sit");
            llStartAnimation(sitAnimation);
            state sitting;
        }
    }    
}


state sitting {
    state_entry() {
    }

    // Oddly, this event listener NEEDS to be here.
    // If it isn't, then when you shift out of this state,
    // then event goes dead in default.
    collision_start (integer total_number) {
    }

    // Assume sitting, thus any CHANGED_LINK means standing.        
    changed(integer change) {
        if (change & CHANGED_LINK) {
            llStopAnimation(sitAnimation);
            llResetScript();
        }        
    }

}