Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Looking for continuous menu call poseball

Apryl Beaumont
Registered User
Join date: 10 Apr 2007
Posts: 5
05-10-2007 15:21
(Apologies ahead of time as I'm kind of new to this whole scripting thing and I fear I just haven't found that ONE PAGE on the LSL Wiki I need to read to figure this out ...)

I'm trying to create a poseball where you can choose between multiple animations. I've got most of it down, but I'm having problems with two things:

1. When a person sits on the poseball, I want the script to call up an llDialog with the list of available animations. (In the following script this is done in the function fDialog.)
2. After a person chooses an animation, I want the script to call the llDialog AGAIN so the person can choose a new animation.

As the script is now, I can only get the llDialog to call if the person clicks on the (invisible) poseball. I'd really like the llDialog to launch upon sit, and again after the person chooses an animation. Here's the entirety of the script since I don't know where I'd need to place the calling code ...

CODE

// Testing script by Apryl Beaumont
string ANIMATION = "nyanya";
integer visible = TRUE;
integer channel = 1001;
key avatar;
key trigger;

show()
{
visible = TRUE;
llSetText("torment", <1,0,0>,1);
llSetAlpha(1, ALL_SIDES);
}

hide()
{
visible = FALSE;
llSetText("", <1,1,1>,0);
llSetAlpha(1, ALL_SIDES);
}

fDialog()
{
llDialog(llDetectedKey(0), "Test dialog", ["Yes", "No"], channel);
}

default
{
state_entry()
{
llSay(0, "Torment ball launching ...");
llSetText("torment", <1,0,0>,1);
llSetSitText("Torment");
llSetAlpha(1, ALL_SIDES);
llSitTarget(<0,0,0.001>, llEuler2Rot(<0,0,0>));
llListen(channel,"","","");
}

changed(integer change)
{
if (change & CHANGED_LINK)
{
avatar = llAvatarOnSitTarget();
if (llKey2Name(avatar) != "")
{
hide();
llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
}
else
{
if (llKey2Name(llGetPermissionsKey()) != "" && trigger == llGetPermissionsKey())
{
llStopAnimation(ANIMATION);
trigger = NULL_KEY;
}
show();
}
}
}

listen(integer chan, string name, key id, string mes)
{
llSay(0, name + " chose option " + mes);
if (mes == "Yes")
{
llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
llStopAnimation(ANIMATION);
ANIMATION = "angry_fingerwag";
llStartAnimation(ANIMATION);
}
if (mes == "No")
{
llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
llStopAnimation(ANIMATION);
ANIMATION = "nyanya";
llStartAnimation(ANIMATION);
}
}

run_time_permissions(integer perm)
{
avatar = llAvatarOnSitTarget();
if (perm & PERMISSION_TRIGGER_ANIMATION && llKey2Name(avatar) != "" && avatar == llGetPermissionsKey())
{
trigger = avatar;
llStopAnimation("sit");
llStartAnimation(ANIMATION);
llSetAlpha(0,ALL_SIDES);
llSetText("",<1,1,1>,1);
}
}

touch_start (integer detected)
{
fDialog();
}
}


Any help anyone could give me would be most appreciated. Thanks!
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
05-10-2007 15:36
You need to add the fDialog in three places:
CODE

...
changed(integer change)
{
if (change & CHANGED_LINK)
{
avatar = llAvatarOnSitTarget();
if (llKey2Name(avatar) != "")
{
hide();
llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
1) add this line this will bring in the dialog menu the first time on sit
CODE

fDialog();

...
CODE

listen(integer chan, string name, key id, string mes)
{
llSay(0, name + " chose option " + mes);
if (mes == "Yes")
{
llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
llStopAnimation(ANIMATION);
ANIMATION = "angry_fingerwag";
llStartAnimation(ANIMATION);
2) add here for remenu after selecting animation
CODE

fDialog();

CODE

}
if (mes == "No")
{
llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
llStopAnimation(ANIMATION);
ANIMATION = "nyanya";
llStartAnimation(ANIMATION);
3) and again here
CODE

fDialog();

...
Apryl Beaumont
Registered User
Join date: 10 Apr 2007
Posts: 5
05-10-2007 18:12
I tried that, but the dialog box still won't come up. Is there some sort of rule about when/where you can trigger the dialog box that isn't in the LSL Wiki entry on llDialog? :/
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
05-10-2007 18:19
Chances are its that llDetectedKey(0) that is returning null in fdialog.

Try replacing it with avatar (global variable) and see what happens.
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
05-11-2007 05:27
Ok...take the code as described for you before about adding the fDialog() to the changed event and listen...and remove the touch event.

Change the following
CODE
fDialog() 
{
llDialog(llDetectedKey(0), "Test dialog", ["Yes", "No"], channel);
}


To:

CODE
fDialog(key animAV) 
{
llDialog(animAV, "Test dialog", ["Yes", "No"], channel);
}


And instead of using the following to execute this state:

CODE
fDialog();


Use:

CODE
fDialog(avatar);
Apryl Beaumont
Registered User
Join date: 10 Apr 2007
Posts: 5
05-11-2007 11:52
Problems solved. A thousand gratitudes to you and yours. :)