Jump to content
SeeAirAhh Josephina

Hovering Bird script

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";
            }
        }
    }
}
 

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
Posted (edited)
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

Share this post


Link to post
Share on other sites

Thanks, Profaitchikenz -- I hadn't noticed the llSetLinkPrimitiveParamsFast down there.   I just ran my eye over it and saw the llSetPrimitiveParams in the earlier parts of the script and didn't see that llSetLinkPPFast was used later on.    

Share this post


Link to post
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.

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...