Jump to content

Hovering Bird script


You are about to reply to a thread that has been inactive for 1800 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

This script will not work with more than 1 prim, I was hoping someone could help me.

string  default_spot;
string  current_spot;
float   set_x;
float   set_y;
float   set_z;
vector  new_pos;
vector  temp_default;
rotation    new_rot;
integer touch_event = 1;
integer counter = 1;
string  state_current = "rotation";

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

    touch_start(integer total_number)
    {
        if ((touch_event == 1) && (llDetectedKey(0) == llGetOwner()))
         {
            default_spot = (string)llGetPrimitiveParams([PRIM_POS_LOCAL]);
            llSetTimerEvent(0.1);
            touch_event = 0;
        }
        else if ((touch_event == 0) && (llDetectedKey(0) == llGetOwner()))
        {
            llSetTimerEvent(0.0);
            llSetPrimitiveParams([PRIM_POSITION, (vector)default_spot]);
            llSetPrimitiveParams([PRIM_ROTATION, llEuler2Rot(<0, 0, 0> * DEG_TO_RAD)]);
            touch_event = 1;
            counter = 1;
            state_current = "rotation";
        }
        
    }
    
    timer()
    {
        if (state_current == "rotation")
        {
            new_rot = llEuler2Rot(<0, 0, (360.0 + llFrand(-360.0))> * DEG_TO_RAD);
            llSetPrimitiveParams([PRIM_ROTATION, new_rot]);
            state_current = "prep";
        }
        else if (state_current == "prep")
        {
            current_spot = (string)llGetPrimitiveParams([PRIM_POSITION]);
            set_z = 0.05 + llFrand(-0.1);
            temp_default = (vector)default_spot;
            state_current = "movement";
        }
        else if (state_current == "movement")
        {
            new_pos = llGetPos() + <0.05, 0.0, set_z> * llGetRot();
            if ((temp_default.x - new_pos.x < 5.0) && (temp_default.x - new_pos.x > -5.0) && (temp_default.y - new_pos.y < 5.0) && (temp_default.y - new_pos.y > -5.0) && (temp_default.z - new_pos.z < 1.5) && (temp_default.z - new_pos.z > -1.5))
            {
                llSetLinkPrimitiveParamsFast(0, [PRIM_POSITION, new_pos]);
            }
            counter++;
            if (counter == 20)
            {
                llSleep(5.0);
                counter = 1;
                state_current = "rotation";
            }
        }
    }
}
 

Link to comment
Share on other sites

9 hours ago, SeeAirAhh Josephina said:

llSetLinkPrimitiveParamsFast(0, [PRIM_POSITION, new_pos]);

The problem is with "0" which is for an unlinked prim, use 1 for the root prim,, (or LINK_THIS) see http://wiki.secondlife.com/wiki/LlSetLinkPrimitiveParamsFast#llSetLinkPrimitiveParamsFast for more detail

 

As Innula said, you must ensure the script is on the root prim,. and also to not try and move it more than 10 metres at a time using changed to PRIM_POSITION.

 

Edited by Profaitchikenz Haiku
  • Like 1
Link to comment
Share on other sites

9 hours ago, Innula Zenovka said:

At first sight, that looks to me as if it should work for a multiple-prim linkset provided you  put it in the object's root prim.   Have checked on where it is in the linkeset?

Yes, I put it in the root prim and it would not move if it is linked to other prims.

Link to comment
Share on other sites

9 hours ago, Profaitchikenz Haiku said:

The problem is with "0" which is for an unlinked prim, use 1 for the root prim,, (or LINK_THIS) see http://wiki.secondlife.com/wiki/LlSetLinkPrimitiveParamsFast#llSetLinkPrimitiveParamsFast for more detail

 

As Innula said, you must ensure the script is on the root prim,. and also to not try and move it more than 10 metres at a time using changed to PRIM_POSITION.

 

Sweet!  Thank you!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1800 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...