Jump to content

How to detect typing, properly...? [resolved]


Sorimachi
 Share

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

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

Recommended Posts

default
{
    state_entry()
    {
        llSetTimerEvent(0);
    }
  
timer() {
            if (llGetAgentInfo(llGetOwner()) & AGENT_TYPING)
            {
                    llSetAlpha(1.0, ALL_SIDES);
            }
            else
            {
                    llSetAlpha(0.0, ALL_SIDES);
            }
        }
}
        

LSL is beating me up.

My item stays invisible. How do I properly detect typing?

Bonus points if you show me how to mess with glow as well <3

Link to comment
Share on other sites

The main reason that's not working is that the timer never gets switched on.

llSetTimerEvent(0.0) is used to switch off the timer.   You want something that fires about once a second.   

Prim glow can only be set with llSetLinkPrimitiveParamsFast and related functions.   You could change both the glow and the visibility all in the one call (llSetPrimitiveParms and all similar functions can do lots of things all at once) but unfortunately someone once decided (for reasons that must have seemed good at the time) to bundle the prim's alpha setting with the colour setting.   So you have to set PRIM_COLOR, face, colour, alpha.  

Take a look at llSetPrimitiveParams in the wiki. It's one of lsl's most powerful and useful functions, and repays close study.

You may well decide it's simpler just to use llSetAlpha and llSetPrimitiveParams ( [PRIM_GLOW, face, intensity]) separately and not have to worry about the colour.

 

Link to comment
Share on other sites

// TYPING :// * avoid useless changes // -- when the avatar is moving : because he can t type and move at the same time // -- when there is nobody neighbours : because when the avatar is alone he knows himself when he is typing// -- when the prim is shown and we want to show it// -- when the prim is hidden  and we want to hide it// * avoids the flickering of the prim because the avatar starts to write some characters 

// and doesn t hit while 2-3 seconds// so we use a listener to show the prim until the avatar has not finished his message

// Nevertheless it won t avoid the flickering when the avtar writes some characters ,

// and, next, looses his focus on the bar chat in clicking somewhere else// May be changed float T = 0.1; // time of frequency to check the typing state in seconds// Dont change belowfloat actualAlpha;integer listenHandler;integer lastState;// Shows the prim or hides itshowIf( integer boolean){ if ( boolean ) { if ( actualAlpha != 1.0 ) {// we show the prim and activates the listener to wait // a carriage return // we don t need anymore of the sensor llListenControl( listenHandler, TRUE); llSensorRemove(); llSetAlpha( actualAlpha = 1.0 , ALL_SIDES); } } else { if ( actualAlpha != 0.0 ) {// we hide the prim llSetAlpha( actualAlpha = 0.0 , ALL_SIDES); } }}// avoid to change the alpha of the prim when// - we wants to hide it , but it s already hidden// - we wants to show it , but it s already shownbufferedDisplay( integer actualState ){ if ( actualState != lastState ) { showIf ( actualState ); lastState = actualState; } }

 

// When the prim is not attached , we show it : it avoids the avatar loose his prim

// if the prim was invisibleinit(){ if ( !llGetAttached() ) { llSensorRemove(); showIf( lastState = TRUE); llOwnerSay("wear me.. i will be hidden.. type to unhide"); } else { llSensorRepeat("",NULL_KEY, AGENT, 20, PI, T); showIf( lastState = FALSE); } }default{ state_entry() { listenHandler = llListen(PUBLIC_CHANNEL, "", llGetOwner(),""); llListenControl( listenHandler, FALSE); init(); } on_rez(integer start) { init(); } attach(key id) { init(); } moving_start() { llSensorRemove(); } moving_end() { llSensorRepeat("",NULL_KEY, AGENT, 20, PI, T); } listen(integer c, string n, key k, string m) { showIf( FALSE); llListenControl( listenHandler, FALSE); llSensorRepeat("",NULL_KEY, AGENT, 20, PI, T); } sensor(integer n) { bufferedDisplay( llGetAgentInfo(llGetOwner()) & AGENT_TYPING ); }}

 There is no way to detect typing properly :

if someone writes some characters on his  chat bar , doesn t use return , clicks somewhere else, the viewer will send to

the simulator than the agant has finished typing , but it s not true , because the avatar jas not finished his message.

Nevertheless , you may use this script above .. It s already better than use a permanent timer, and to change the prim always

Link to comment
Share on other sites

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