Jump to content

Dance Balls tutorial


bbrasta Boa
 Share

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

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

Recommended Posts

Hello again :)

I am following a Dance Balls tutorial, step by step, in which more options are added in each version, I am in a step in which when you click on the ball, it starts to dance, and when you click again on the ball, the avatar stops dancing, but for some reason, this part of the code doesn't work. In fact, if the tutorial script is copied, it gives an error.
This is the part that gives an error:

Quote

touch_end(integer c) { key av = llDetectedKey(0); key oldav = llGetPermissionsKey(); if (gDancer != NULL_KEY && oldav != NULL_KEY) { // if someone was already dancing, stop them stopDance(); gDancer = NULL_KEY; } if (av != gDancer) { // if we weren't dancing already, start us gDancer = av; requestDance(av); } }

The requestDance(av); give me an error, I tryes to remove the "av" in that part, so now I can save the compilation, but when the avatar is dancing, and I click again in the Ball, the avatar doesn't stop dancing, any advice?

Thanks in advance.

Link to comment
Share on other sites

touch_end(integer c) 
{ 
	key av = llDetectedKey(0); 
	key oldav = llGetPermissionsKey(); 
	if (gDancer != NULL_KEY && oldav != NULL_KEY) 
	{ // if someone was already dancing, stop them 
		stopDance(); 
		gDancer = NULL_KEY; 
	} 
	if (av != gDancer) 
	{ // if we weren't dancing already, start us 
		gDancer = av; 
		requestDance(av); 
	} 
}

We would need to know the error message to get some idea why it's choking on that line. After reformatting i so I can see the block structure there's little obviously wrong, can you post what it actually says? 

It would also help if you included the functions stopDance() and requestDance(), as the hints you have given regarding how you stopped the error suggest that requestDance does not take a key as the argument.

The only alternative is that either  gDancer or oldAv are NULL_KEY at that point, so no call is made to stopDance?

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

Hello and thanks for reply :)

This is what I have now, having removed the "av" from the requestDance from the end of the script. If I don't delete it, it gives me the "Function call mismatches type or number of arguments" error.

Quote

integer gControlCh = 99; 
vector gSitOffset = <0,0,1>;
vector gSitRotation = <0,0,0>;
key gDancer= NULL_KEY; // who is dancing?
string gSitText = "Pose Ball 4 Extended Listen Ball";
vector gSitTextColor = <1,1,1>; 

requestDance() 
{
 if (gDancer != llGetPermissionsKey() || 
 (llGetPermissions()&PERMISSION_TRIGGER_ANIMATION) == 0) {
 llRequestPermissions(gDancer, PERMISSION_TRIGGER_ANIMATION);
 } else {
 startDance();
 }
}
HideDanceBall()
{
 llSetText("Dancing", gSitTextColor, 1.0);
}
SHowDanceBall()
{
 llSetText(gSitText, gSitTextColor, 1.0);
}
startDance() 
{
 HideDanceBall();
 llStopAnimation("sit"); 
 llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION, 0));
}

stopDance()
{
 llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION, 0));
 llStartAnimation("stand"); 
 
SHowDanceBall();
}

default {
 on_rez(integer p) 
 {
llResetScript();
}   

 state_entry() 
 {
 SHowDanceBall();
 llSitTarget(gSitOffset, llEuler2Rot(gSitRotation * DEG_TO_RAD));
 llSetSitText(gSitText);
 llListen(gControlCh, "", NULL_KEY, "");
 
 }
 
 listen(integer ch, string name, key id, string m) {
 if (m == "show") {
 SHowDanceBall();
 } 
 else if (m == "hide") 
 {
 HideDanceBall();
 } 
 else if (m == "dance") 
 { 
 if (gDancer == NULL_KEY) 
 {
 gDancer = id;
 requestDance();
  }
 }
 else if (m == "stop") {
 if (id == gDancer) {
 stopDance();
 gDancer = NULL_KEY;
 }
 else if (m == "reset") {
 if (id == llGetOwner()) {
 llResetScript();
   }
  }
 } 

changed(integer change) 
{
if (change & CHANGED_LINK) 
{
key avatar = llAvatarOnSitTarget();
if (llAvatarOnSitTarget() != NULL_KEY) 
{
gDancer = avatar;
requestDance();
 }
else 
{
stopDance();
gDancer = NULL_KEY;
   }
  }
 }
 
 run_time_permissions(integer perms) 
{
 if (perms & PERMISSION_TRIGGER_ANIMATION) 
{
 startDance();
 } 
 else 
{
 llWhisper(0, llKey2Name(gDancer)+" can't dance!");
 gDancer = NULL_KEY;
  }
 }
touch_end(integer c)
{
 key av = llDetectedKey(0);
 key oldav = llGetPermissionsKey();
 if (gDancer != NULL_KEY && oldav != NULL_KEY) 
 { 
 stopDance();
 gDancer = NULL_KEY;
 }
 if (av != gDancer) 
 {
 gDancer = av;
 requestDance();
  }
 }
}

 

Link to comment
Share on other sites

Ok, that makes sense, because requestDance() does not take any arguments but instead uses the global variable gDancer.

I think the script you're trying to get running is quite old and there have been several recent changes to the way animations are treated when an avatar stands. There is no longer any need to stop an animation when an avatar actually stands, this seems to be done by the viewer or the server, unsure which.

The main time you will need to explicitly stop an animation is when the seated avatar is going to have a different animation played, at which point you fist of all stop what they're currently being animated by and then start the new one.

In your tutorial only a single animation is available, so I suggest you comment out the blocks of code that try to stop the animation but leave inn the line that resets gDancer to NULL_KEY, and see what then happens.

 

ETA

I just read back through your first post and realise you are saying that when you click the ball a second time you expect the avatar to stop dancing. The code here requires that there is already an avatar for whom permissions have been obtained, and that the current dancer is also an avatar. I suggest you add some llOwnerSay statements around that code to see what the two keys are in order to see if the block of code that calls stopDance is actually getting entered? Likewise, in the stopDance() function, add an llOwnerSay to announce when the function i entered, so you can check it is actually being called. If there is no avatar for whom permissions have been obtained then the block will not be entered.

Edited by Profaitchikenz Haiku
  • Thanks 1
Link to comment
Share on other sites

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