Jump to content

HUD controlled attachment animation


Basement Desade
 Share

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

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

Recommended Posts

I am trying to trigger an animation from an attached item. I know the HUD script is sending because a similar script in my item is being triggered, I just can't seem to get this one to run the anim. I suspect it has to do with the permissions call I added for the animation. This script compiles and "runs," it just doesn't do anything:

 

 

integer handle;
integer mychannel;

integer Key2Number(key objKey) {
    return ((integer)("0x"+llGetSubString((string)objKey,-8,-1)) & 0x3FFFFFFF) ^ 0x3FFFFFFF;
}

key owner;
default
{
    on_rez(integer start_param)
{
llResetScript();
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}

state_entry()
    {
       
    }

    attach(key attached)
    {
        if(attached){
            llListenRemove(handle);
            owner = attached;
            mychannel = Key2Number(owner);
            handle =llListen(mychannel,"","","");
        }
        else{
            llListenRemove(handle);
        }
    }

    listen(integer channel, string name, key id, string message)
    {
 if (message == "on")
        {
            llStartAnimation("animation");
        }
else if (message == "off")
        {
           llStopAnimation("animation");
        }

    }
}

 I further suspect it is just a dumb little something I am missing. Any and all help much appreciated. :)

Link to comment
Share on other sites

There are two serious problems that I can see immediately.

The first is that you request animation permissions in the on_rez event, but after you've called llResetScript().   Nothing gets executed in an event after llResetScript so, in effect, you never ask for animation permissions.

The listener needs attention, too.    The channel is going to be some enormous number that 's not readily predictable by the  user (for me it would be 754854604).   Normally you'd use that sort of method to general a channel for dialogues, not chat commands.    But I'm not sure that's the immediate issue, since the script, I think, will reset itself on_rez, before the attach event fires, so you never open a listener at all.

So, in short, it's the llResetScript in the on_rez event that's the problem, and I don't think it needs to be called at all.    I know a lot of people do reset their scripts out of habit, but to my mind it's a bad habit unless there's a really good reason for doing it, like you want to make sure old settings are wiped and new ones recorded -- positions, for example.

Try something like this:

integer SomeChannel = 5;integer handle;key owner;init(){	owner = llGetOwner();	llListenRemove(handle);	handle = llListen(SomeChannel,"",owner,"");	if (llGetAttached()){		llRequestPermissions(owner,PERMISSION_TRIGGER_ANIMATION|PERMISSION_TAKE_CONTROLS);//keep going in no script areas	}}default{	state_entry()	{		init();	}	attach(key attached)	{		if(attached){			init();		}	}	changed(integer change)	{		if (change & CHANGED_OWNER){			init();		}	}	run_time_permissions(integer permissions)	{		if(permissions & PERMISSION_TAKE_CONTROLS){			llTakeControls(CONTROL_FWD,TRUE,TRUE);			//Need to take controls to keep going in no script areas, even though there's no control event.  Set this to TRUE,TRUE -- otherwise you can't touch stuff in mouselook		}	}	listen(integer channel, string name, key id, string message)	{		//do stuff	}}

 

Link to comment
Share on other sites

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