Jump to content

Typer Script Help Needed


TauniKingston
 Share

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

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

Recommended Posts

Hello... I need to create a TYPER that will make the object appear, play the animation (and loop till typing is stopped) then vanish the item... I have a script that the item appears  then vanishes when typing but cannot for the life of me figure out how to make an animation play as well.  Do I need a separate script for this?  And if so, could someone help me with that script please?  here is what I have so far:

default
{
    state_entry()
    {
        llSetTimerEvent(0.1);
    }
    timer()
    {
        if (llGetAgentInfo(llGetOwner()) & AGENT_TYPING)
        {
            llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
        } 
        else
        {
            llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
        }   
    }
}
 

 

Thank you in advance for your assistance.

 

Link to comment
Share on other sites

Create a global integer flag(call it iType maybe) to keep track of whether typing has already started.  In your first if test in the timer event, start the looping anim and set the flag to TRUE  when typing starts. Otherwise leave it FALSE.    Set iType to FALSE in the second if test and stop the anim when you sense that the agent has stopped typing.  On successive passes through the timer event, that first if test will always tell you whether the anim needs to be restarted or can be left unstarted.

Edited by Rolig Loon
Cleaner wording
  • Like 2
Link to comment
Share on other sites

Animation is a bit trickier because you need to ask the avatar for permission to animate them (which in the case of a worn object like a typer would be automatically granted, but you still need to ask for it)

integer on=FALSE;
default
{
    state_entry()
    {
        llSetTimerEvent(0.1);
    }
    attach(key ID)
    {
      if(ID)
      {
          llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
      }
    }
    timer()
    {
        if (!on && llGetAgentInfo(llGetOwner()) & AGENT_TYPING)
        {
            llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
            on=TRUE;
            if(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
              llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
        } 
        else if(on)
        {
            llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
            on=FALSE;
            if(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
              llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
        }   
    }
}

That should work, I added a global variable 'on' as well to avoid triggering the animation multiple times.

Edited by Quistessa
Woops, realized the permissions should probbaly be asked for every time you attach the object, not just when the script starts.
  • Like 3
Link to comment
Share on other sites

doing a double take, I think my logic might have been a bit flawed. you probably need something more like:

    timer()
    {	integer typing = llGetAgentInfo(llGetOwner()) & AGENT_TYPING;
     	if(typing+on !=1) return; // do nothing if the typer is in the correct state.
     	on = !on;
        llSetLinkAlpha(LINK_SET, (float)on, ALL_SIDES);
        if(on)
        {
            if(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
              llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
        } 
        else
        {
            if(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
              llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
        }   
    }

 

Link to comment
Share on other sites

Or

timer()
{
    integer typing = llGetAgentInfo(llGetOwner() & AGENT_TYPING);
    if (typing)
    {
        if (!on)
        {
            on = TRUE;
            if(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
            {
                llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
            }
        }
    }
    else
    {
        if (on)
        {
            on = FALSE;
            if(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
            {
                llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
            }
        }
    }
}

assuming that on is a global integer variable.

  • Like 2
Link to comment
Share on other sites

  • 4 weeks later...
You are about to reply to a thread that has been inactive for 1079 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...