Jump to content

Simple HUD Script


JackRipper666
 Share

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

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

Recommended Posts

Hi I am trying to make just a simple script where if I place a gesture that has an animation and sound in it. Then put it in a object like a cupe. Then Put a texture on it with a play button. How would I write a script to define the play button is the trigger to make the gesture play? And if I have two do it separate where it can't be a gesture only a animation and sound file. I uploaded the sound file but the .bvh file of the stock belly laugh animation I can't find that. Where would that be lol? Sorry for all the questions but I can't find answers to them on Second Life wiki the examples aren't making sense to me. =/ Any help would be much appreciated, thank you!

Link to comment
Share on other sites

You are asking mostly general questions about scripting, so the smartest thing to do is

(1) spend some time with the tutorials at http://wiki.secondlife.com/wiki/LSL_Tutorial to get a basic understanding of LSL and some feel for basic scripting logic

(2) find some freebie scripts that are sort of like what you are aiming for and take them apart.  Modify them a little bit at a time until they fit your needs.  There are MANY places in world that have collections of free or low-cost scripts.  Just use your Search tool and go exploring.

It's hard to give you any more specific advice without seeing the script you are writing.  Once you have made some progress and have questions about it, though, please come back and post your script here.  That's what this forum is for.  :smileywink:

Link to comment
Share on other sites

Hi Jack.

As Rolig says, your query is really too general to answer specifically but one place you could start is the example animation script in the Wiki which will cycle through SL's internal animations on touch. The laugh anim is in there somewhere and you should be able to isolate it while trying to understand the general principles of LSL.

The script is here: http://lslwiki.net/lslwiki/wakka.php?wakka=ExampleAnimationScript

As for the play button, you drop the script in the prim you want to have act as the button or you could get even more complex and define an area of the surface texture to act as the button by using llDetectedTouchUV in place of the general touch action.

Link to comment
Share on other sites

Thanks guys, I really appreciate this help. Yea that's exactly what I was looking for Carbon! Had no idea that llDetectedTouchUV even existed. But I am very new I guess to scripting even though I feel I understand it some what. I'm not in amateur in all area's of the computer. At least not with hardware and art. lol programming though I got a long way to go. I'm just gonna keep playing around with it maybe I can find away to write it up correctly as a script. Thanks again for point me in the right direction! Helps a lot! :smileyhappy:

Link to comment
Share on other sites

Glad to be of help.

Best advice I have is keep revisiting the forums, the scripting one in particular. This is where I pick up most of the info on new or more obscure functions from much more knowledgeable contributors than me without wading through the LSL wiki, which, incidentally, I keep open in a browser window most of the time I'm in SL and trying to build and script.

Also, the College of Scripting in-world has a comprehensive series of tutorials on display boards on the upper floors of their building and there's a worked example of llDetectedTouchUV script for you to read through at leisure.

Link to comment
Share on other sites

Nice I am going to take a  look at it. I actually finally wrote a script well. I feel like I'm piecing together what I understand. I haven't fully memorized how to write this all up. Which I guess to me is really being a scripter lol! But it's a start This is my example of what I was trying ot do. My only issues so far is I have to figure out how to learn the llDetectedUV. So far I found on wiki the code that tells me where I am clicking. But I don't understand how to use the reported information in local chat. Maybe I can find out how it works on that college of scripting in world. Also I need to maybe add one more animation.

I did add a second one but I need to figure out how to make it trigger after the first two. I like how my first two animations go off at the same time because in world one is a laugh emote for the facial expression I wanted and second one that goes off same time is the belly laugh where he is very animated. So if I can just figure out how to add a second animation that plays after the first two that would work well. Otherwise it'll play three animations and the second laugh animation just kinda interrupts the first lol. Oh well I'm getting closer. But hopefully this code will help anyone on here looking for same info.

Only thing you'll need to do since I have it where it just plays what's in the prim content tab. So put in your audio file of a laugh there an it should just play what's ever inside the prim you created. I just get confused since wiki isn't really good at explaining something where I can understand it in human language LOL! The examples are much more helpful. This way I can understand what's going on better.

 

Code::

 

string gAnimName1 = "express_laugh_emote";
string gAnimName = "express_laugh"; // what animation to play?


default
{
    state_entry()
    {
        llSay(0, "LOL");
    }
    touch_start(integer total_number)
    {
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // ask the owner for permission to trigger animations
        llStartAnimation(gAnimName1);
        llStartAnimation(gAnimName); // automatically trigger animation.
        llPlaySound( llGetInventoryName(INVENTORY_SOUND,0),1);
       
    }
             on_rez(integer param)
    {
        llResetScript(); // reset the script as soon as it starts.
    }
            attach(key id)
    {
        integer perm = llGetPermissions();
       
        if (id != NULL_KEY) // make sure we're actually attached.
        {       
            if (! (perm & PERMISSION_TRIGGER_ANIMATION)) // remember to use bitwise operators!
            {
                llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // request permissions from the owner.
          }               
        }
        else
        {
            if (perm & PERMISSION_TRIGGER_ANIMATION)
            {
            }
        }
    }
}

Link to comment
Share on other sites

Nice work so far.  :smileyhappy:

OK....   llDetectedTouch functions give you a vector as output. The X and Y components tell you relative positions on their respective axes, on a scale from 0.0 to 1.0 with the <0,0> position inthe lower left (southwest) corner of the touched face (or texture, depending on which function you used).  The Z coordinate is meaningless.  So, you can use that information to find exactly what spot a user clicked, or what area s/he clicked in.

 

touch_start(integer num){    vector My_Pos = llDetectedTouchST(0);    integer Face = llDetectedTouchFace(0);    if (( My_Pos.x <= 0.5) && (My_Pos.y <=0.5))    {        llSay(0,"You just touched somewhere in the SW corner of face #" + (string)Face);    }}

 As for your other question.... You'll need to use a timer event.  Fire the first animation in the touch_start event and set a timer for however long it takes to complete that animation.  Then fire the second animation in the timer event.  Don't forget to turn off the timer after it fires.

The only major thing that's missing from your script is a run_time_permissions event.  It's being triggered by the llRequestPermissions function in your attach event, but you need the run_time_permissions event to actually process the permission request.  The wise thing would be to use that event to pass control to a second state, in which you place the touch_start event and the timer.  That way, those events can't be triggered until permission is given.

Link to comment
Share on other sites

Oh ok I'll have to try this out soon. I did get one of the examples to work on wiki finally as well for the coords on x an y I think it was of where I touch the hud. I'll try to fix that part of the code without messing up what I already put together lol. Hm.. one problem I am having though is only my gesture can be herd but not the laugh that is inside the HUD. I don't know why that is because I did set it in the code as you can see to 0 for public chat. So I'm puzzled as to why it's not playing in virtual world and only to me when I click it. Again though if I just use the gesture it works. I might just use that though to keep my HUD area a little less clutered. But I'd hate to waste so much time if I can't resolve what should be a simple issue I guess.

Link to comment
Share on other sites

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