Jump to content

Script to initiate touch and to animate the mesh


trondvis
 Share

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

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

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

You are about to reply to a thread that has been inactive for 3320 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...