Jump to content

Script to initiate touch and to animate the mesh


trondvis
 Share

Recommended Posts

Hi,

I have tried for Linden scripting for animating a linked mesh.The mesh is animated and also a touch event is initiated .The code is below

integer total_prims;
integer link_counter;
string strNotecard;
default
{
    state_entry()
    {
        total_prims = llGetNumberOfPrims();
        llSay(0, (string) total_prims);
        llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
        llSetTimerEvent (0.2);
    }
    
    timer()
    {
        integer next_link_counter = (link_counter % total_prims) + 1;
        llSetLinkPrimitiveParamsFast( link_counter,
            [ PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 0.0
            , PRIM_LINK_TARGET, next_link_counter
            , PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 1.0
            ]);
        link_counter = next_link_counter;
    
         strNotecard = llGetInventoryName(INVENTORY_NOTECARD,0);
          if(llGetInventoryType(strNotecard)!=INVENTORY_NOTECARD)
           {
             llOwnerSay("There is no notecard in my inventory!");
        }
        else { 
            llOwnerSay("I have found a notecard called "+strNotecard+" and I will give that to whoever touches me.");
        }
    }
     touch_start(integer num_detected)
    {
        if(strNotecard){ 
        llGiveInventory(llDetectedKey(0), strNotecard); 
        }
    }
   changed(integer change) 
    { 
        if(change & CHANGED_INVENTORY){
            llResetScript();
        } 
}
}

 

The script is working fine but there is one problem !!

The  message  

I have found a notecard called "+strNotecard+" and I will give that to whoever touches me.

is coming repeatedly   .

How can i get out of this problem

 

Link to comment
Share on other sites

Why is that bit of code in your timer event at all?  It has nothing to do with the stuff you are trying to change.  (In fact, it's almost irrelevant to your entire script.)  If you really need it at all, move it to the state_entry event, say it once, and be done with it.  If you truly feel that it has to be said periodically, count the timer cycles and send it only once every 100 cycles or more, using the same % approach that you are already using with link_counter.

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

 Share

×
×
  • Create New...