Jump to content

Problems with the Changed Event


Streak Wildung
 Share

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

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

Recommended Posts

Hey guys, I have an issue with the changed() event and I was wondering if anyone would have some insite to this.

I'm doing a little RLV work and in my default state it listens for the RLV commands, one it recieves and verifys the commands it changes to the RLV state I have set up, checks to see if the user is sitting on something or not and sets all of it's variables.  Now I have the changed() even in my RLV state set to monitor for a link change, if the link changes it does a litlte house keeping and switches back to the default state.

Problem is, the changed() even isn't triggering at all, literally.  I put a little debug code (just an ownersay) inside the change() even before any type of logic checks.  It won't even trigger, no matter what changes.

Has anyone else had this issue?  If you have, what am I doing wrong?  Below is a small code snippet.

 

state rlv_command {
    changed(integer what_changed) {
        llOwnerSay("Pre if statemnt");
        if(what_changed & CHANGED_LINK) {
            llOwnerSay("Change State");
            if(sit == TRUE) {
                llSay(0, "no longer sitting");
                sit = FALSE;
                state default;
            }
        }
    }
    
    state_entry() {
        if(llGetAgentInfo(llGetOwner()) & AGENT_SITTING) {
            //llOwnerSay("Avatar is sitting");
            sit = TRUE;
        }
        
        //llOwnerSay("rlv command state entered");
        llSetTimerEvent(10.0);
    }
    
    timer() {
        llSay(0, "Time Reached");
        llSetTimerEvent(0.0);
        exploded_rlv_message = [];
        state default;
    }
}

Aside from Hello World, that's pretty basic, as I said that changed() even won't trigger at all.  I call this state from a listen() even in the default state.

Thanks for any input!

Link to comment
Share on other sites

That looks like it ought to work, but you're using a more complicated method than you need to.  All you really need is a new global integer variable and a changed event that looks like this:

changed (integer change){    if (change & CHANGED_LINK)    {        if (llGetNumberOfPrims() < gOldNumber)   // There's your new variable, gOldNumber        {            state default;        }        gOldNumber = llGetNumberOfPrims();    }}

That will ignore any change that happens when someone sits down, and will send execution back to state default when someone stands up.  If you want to make it maybe a little more robust, you can check specifically for llAvatarOnSitTarget, but this method lets you avoid having to set a sit target in the first place.

 

   

  • Like 1
Link to comment
Share on other sites

You're absolutely right, it is far more complicated then it needs to be (I like your's better!  :P)  I was quickly jotting some code in to test some ideas I had and hadn't really optimized, so it's a tad messy.

What really baffles me, is no matter what...the changed() even just will not trigger, like at all.  I personally haven't had this to happen before but admitedly I've never used changed() that much except for checking for inventory changes.  This one has me a litlte stomped because like you said, even if it's more complicated it should still work.

I figure I'll give it a try tonight when I get home from work, maybe it was just something with SL last night and it'll all be working again (what could have caused it is a mystery, but who knows!).

Thanks for your input and I'll defintely be stealing you snippet!  :P

Link to comment
Share on other sites

Well, I don't know the geometry of your setup, but it could have something to do with the fact that you are using llGetAgentInfo to determine whether someone is sitting.  That doesn't necessarily tell you whether the person is sitting on your object.  You might also try

if(llGetAgentInfo(llGetOwner()) == AGENT_SITTING) 

instead of

if(llGetAgentInfo(llGetOwner()) & AGENT_SITTING) 

The two ought to be equivalent, but I've seen your method fail before.  Dunno why, offhand.

Link to comment
Share on other sites

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