Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Touch Animator Help

ChaiBoy Rang
Registered User
Join date: 9 Mar 2007
Posts: 29
09-13-2008 19:15
i am trying to learn the basics of scripting so bare with me. I am trying to make a simple script. Click it activates an animation click again to stop it.

here is what I have:

CODE

string ANIMATION="dance 1";
integer doIt = TRUE;
key target = "";

default
{
state_entry()
{
llSay(0, "Animation ready");
target = llGetOwner();
}

touch(integer detected){
llRequestPermissions(target, PERMISSION_TRIGGER_ANIMATION);


}

run_time_permissions(integer perms)
{
if(perms & PERMISSION_TRIGGER_ANIMATION)
{
if(doIt == TRUE)
{
llStartAnimation(ANIMATION);
doIt = FALSE;
}else{
llStopAnimation(ANIMATION);
doIt == TRUE;
}
}
}
}



Now the problem i have is that it keeps asking for permission every time i click instead of the first time. I got the basic code from dance ball scripts but don't understand where I am going wrong. Also When I touch it the request will pop up 2 or 3 times.

Any clues about what i need to do to fix this?

Thanks

Chai
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
09-13-2008 22:00
for the second issue use touch_start() instead of touch()

as for the first thats exactly the way it was programmed

so you need a way to know if the av has already touched it or not
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
09-14-2008 00:13
Your script will always ask for permission to animate. This permission is only automatically granted for the attachments and the objects on which you sit.

If this object is only meant to animate yourself, you can make it ask for permission only once on rez with your own key. Otherwise, the most simple way is to make the AV sit on click.

Script-wise:
From: someone

key Sitter;

default
{
state_entry()
{
llSitTarget(<1.0, 0.0, 0.0>, ZERO_ROTATION); // Needs some tuning
llSetClickAction(CLICK_ACTION_SIT);
}

changed(integer change)
{
if (change & CHANGED_LINK)
{
Sitter = llAvatarOnSitTarget();
if (Sitter != NULL_KEY)
{
llRequestPermissions(Sitter, PERMISSION_TRIGGER_ANIMATION);
}
else
{
llSetClickAction(CLICK_ACTION_SIT);
}
}
}

run_time_permissions(integer perms)
{
if (perms & PERMISSION_TRIGGER_ANIMATION)
{
llStartAnimation("dance 1";);
llSetClickAction(CLICK_ACTION_TOUCH);
}
}

touch_start(integer num)
{
if (llDetectedKey(0) == Sitter)
{
llUnSit(Sitter);
}
}
}

Pasted and copied from world. Quote me to retrieve the layout.
ChaiBoy Rang
Registered User
Join date: 9 Mar 2007
Posts: 29
09-15-2008 04:24
thanks for help with touch issue.

The permission thing has me confused. The current dance balls i've encountered now have you touch to start and then you can click them again to get a dance menu without asking for permission again?

Even the old dance balls if you clicked again would just stop the animation. mine will try to get permission to stop.

So there has to be some function I'm missing. there gotta...lol

Thanks,

Chai