Jump to content

Need Help on Dialog Script


Icky Spot
 Share

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

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

Recommended Posts

Alright, i have no idea how to change my typing script so it can be selected via a dialog menu. Originally, i just had an object i made with a female type animation in it, and the other one had the male typ animation in it... and you could turn it on/off by touching it. Well now i would prefer to have all of that in one script and work via dialog. Probably super easy for any mediocre scripters out there, but i can't figure some things out.

First, i'll show you how far i got and then will explain the parts i can't do.

 

key toucher;
list tools = ["Type AO","Male","Female"];
string msg = "\nPlease choose an option:";
integer anim = llGetInventoryName(INVENTORY_ANIMATION); //this is totally wrong
integer power = FALSE;
integer listen_id;
integer unique_channel;
integer create_unique_channel(key id) {
    return 0x80000000 | (integer)("0x" + (string) id);
}
 
default {
    state_entry() {
        unique_channel = create_unique_channel(llGetKey());
        llListen(unique_channel, "",  NULL_KEY, "");
    }
 
    touch_start(integer total_number) {
        toucher = llDetectedKey(0);
        if (toucher == llGetOwner()) {
            llDialog(toucher, msg, tools, unique_channel);
            listen_id = llListen(unique_channel, "", toucher, "");
            }
        }
// 
    listen(integer channel, string name, key id, string message) {
        if (message == "Type AO") {
            power = !power;
            llSetTimerEvent((float)power);
            if(power) llOwnerSay("Type AO On");
            else llOwnerSay("Type AO Off");
        }
        else if (message == "Male") {
            anim == "boytype";            // no idea how to do this part
        }
        else if (message == "Female") {
            anim = "girltype";               // ...or this part
        }
    }
//    
    timer() {
        if (llGetAgentInfo(owner) & AGENT_TYPING) {
            llStartAnimation("anim");    // also not sure about this part
        }        
        else {
            llStopAnimation("anim");
        } 
    }
}

 

So it's pretty straight forward, i want 3 basic choices, Type AO turns the typer on and off, then the Male/Female selects the specific animation. As you can probably already notice there are parts that are totally wtong lol. I sorta just filled in wild guesses where i don't know what to do.

 

First is the "integer anim = llGetInventoryName(INVENTORY_ANIMATION);" at the very top. I will have two animations in the object, one called girltype, and one called boytype. I'm not sure how to make it so when the user chooses "Male" on the dialog, it selects the boytype animation.

Second is the message part "else if (message == "Male")" that i mentioned above. I don't know how to choose the specific animation if the user chooses the "Male" or "Female" option.

The last part would be in the timer. For now i just put "anim" to start and stop the selected animation chosen.

 

As you can see i really have no idea what i'm doing... i can figure certain things out on my own but this is a little too complicated for me. I just want to make my script a little more user friendly than what i had originally. Can anyone help me out and show me what to do?

 

Many thanks.

Link to comment
Share on other sites

You have a very good start.  The biggest problem, as you noticed, is the way you are identifying the animation.  Instead of using the global variable anim the way you have, replace it with

string anim;

That's all you need there.  Then, in the listen event, that's where you identify which animation to use, as you already have:

else if (message == "Male") {            anim == "boytype";         }        else if (message == "Female") {            anim = "girltype";        }

Assuming that those are the exact names of the animations in the object's inventory,  that should do it.  When you get to the timer event, the value of your anim variable will be whatever was set in the dialog, so that should be OK too.  Just take the word "anim" out of quotes.

The next problem you are going to have, though, is that you don't have the user's permission to animate.  I assume that you are going to be using this in a HUD, so one way to handle that is to make state default contain an attach event like this ...

    attach (key id)    {        if(id)        {            llRequestPermissions(id,PERMISSION_TRIGGER_ANIMATION);        }    }

 and a run_time_permissions event that chages states when permission has been granted ...

    run_time_permissions (integer perm)    {        if (perm & PERMISSION_TRIGGER_ANIMATION)        {            state running;        }    }

 With a few other small changes along the way, your script could look something like this (untested but it compiles) ...

 

key toucher;list tools = ["Type AO","Male","Female"];string msg = "\nPlease choose an option:";string anim;integer power = FALSE;integer listen_id;integer unique_channel;integer create_unique_channel(key id) {    return 0x80000000 | (integer)("0x" + (string) id);} default{    state_entry()    {        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);    }    attach (key id)    {        if(id)        {            llRequestPermissions(id,PERMISSION_TRIGGER_ANIMATION);        }    }    run_time_permissions (integer perm)    {        if (perm & PERMISSION_TRIGGER_ANIMATION)        {            state running;        }    }}state running{    state_entry()    {        unique_channel = create_unique_channel(llGetKey());        listen_id = llListen(unique_channel, "",  NULL_KEY, "");    }    attach(key id)    {        if(id)        {            state default;        }    }     touch_start(integer total_number)    {        toucher = llDetectedKey(0);        if (toucher == llGetOwner())        {            llListenControl(listen_id, TRUE);            llDialog(toucher, msg, tools, unique_channel);        }    }     listen(integer channel, string name, key id, string message)    {        llListenControl(listen_id,FALSE);        if (message == "Type AO")        {            power = !power;            llSetTimerEvent((float)power);            if(power)            {                llOwnerSay("Type AO On");            }            else            {                llOwnerSay("Type AO Off");            }        }        else if (message == "Male")        {            anim = "boytype";        }        else if (message == "Female")        {            anim = "girltype";        }    }        timer()    {        if (llGetAgentInfo(llGetOwner()) & AGENT_TYPING)        {            llStartAnimation(anim);        }                else        {            llStopAnimation(anim);        }     }}

 

 

  • Like 1
Link to comment
Share on other sites

You freakin rule!

 

TY Rolig, i really appreciate it and now i understand how to do this kinda stuff for next time! My friends, who are obviously better scripters than i, always tell me i overthink things too much, and apparently thats what i was doing here, too.

Link to comment
Share on other sites

It's for an arm attachment. And its working good, there's just one minor problem... when i first attach it then press the 'Typing AO' option in the dialog to turn it on, i get a script error saying  - could not find animation '' - until you actually select one of the anims then it works perfect. I'm guessing that's because when no anim is selected it's still trying to play something?

I'm gonna play with is and see if i can figure it out.

Link to comment
Share on other sites

Good catch.  Until you click the dialog button to select an animation, there's none defined.  So pick one and make it the default.  Just add

anim = "girltype";

at the top of your touch_start event so that it's always the one that plays until you change it.  The stopping, starting business is probably in your anims themselves, as you said.  You might be able to beat it, though, by tricking the viewer into deliberately restarting the anim each time the timer is triggered.  Try

llStopAnimation(anim);

llStartAnimation(anim);

instaed of just starting the anim.

 

  • Like 1
Link to comment
Share on other sites

Ha! TY... yeah i managed to figure it out prlly like 2 seconds before u posted that. Thanks again for all the help Rolig, its working perfectly now! I put the 'boytype' anim as default cuz i think its gonna be mostly boys buying this arm attachemt. :matte-motes-wink-tongue:

Link to comment
Share on other sites

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