Jump to content
Sign in to follow this  
plushsanchez

A complete noob scripting question HUD

Recommended Posts

I have next to no experience with scripting, that is why I came to the experts.

Can anyone help or point me in the right direction.

 

I am creating an item that one can hold in their hands and sip from.  I would like for that item to include a timer to finish drinking and also a visual hud that will also be times.  I would also like to add sounds and chat emotes.  Is this even possible, if so, can any point me in the right direction?

 

 

Any help will be greatly appreciated.

 

Thanks

Share this post


Link to post
Share on other sites

It's certainly possible to make an object -- a cup -- that has an animation that runs for a while and then stops. That sort of thing is done all the time. All you need to do is trigger a llRequestPermissions statement in one event (probably a touch_start event) and then start the animation and set a timer in the run_time_permissions event.  When the timer event triggers, stop the animation.  You'll want to look in the LSL wiki for the llRequestPermissions, llStartAnimation, and llStopAnimation functions and to review how timers work.

I am not sure what that has to do with a HUD, since you don't need a HUD for that, and I have no idea what you mean by a "visual HUD".  If you want to put sounds and chat emotes into your cup's script, you can put those anywhere.

Share this post


Link to post
Share on other sites

Thank you for your response.

 

The visual event, ok there is an item on MP that is a drug.  When you "wear" it eventually you will see colors and other things on your screen.  I'm pretty sure it's a hud (maybe it's called something else in scripting), I've already created it and it works fine. The goal is to avoid having the user wear two different items.  I want to combine the two.

 

Forgive me if I'm not being clear, I've very new to this.

Share this post


Link to post
Share on other sites

You can sort of do that, but only in very limited circumstances.

The main trouble is that anything attached to a HUD point is visible only to its wearer. Usually one would not want the drug itself to be a hallucination. So, for most of the likely cases, you will have to keep the handheld and HUD part as separate attachments.

The one exception would be if you actually want only the wearer to see the handheld part. If that is the case, and the handheld part is rigged, then you can just link it to the HUD piece.

Even if this leaves you with a two-attachment item, you might still be able to exploit it to make interesting rigged things grow out of the avatar, that only the avatar can see.

Share this post


Link to post
Share on other sites

Thanks Cerise.

 

Yes I would want the user and everyone else to see the handheld part, and only the user to see the visuals.  I am going to see how I can make this work.  I'm pretty sure that it can be done, since there is a product out there that is similar, but I'm thinking they did some real fancy foot work to do it, and I just don't have those skills. loll  So I'm finding my own feet. :/

 

 

Share this post


Link to post
Share on other sites

This forum is here to facilitate conversations among scripters. It's a good place to come when a scripter has a discovery to share or gets stuck at a nasty spot in something s/he's writing. We won't write a script for you, but we'll offer examples or do whatever we can to point you in the right direction, as the OP asked here.  Some responses do get round-about, especially when it's hard to know how much the OP knows or has tried already, but I hope most of them aren't too mysterious.  :smileywink:

Share this post


Link to post
Share on other sites

I would have the cup, when it's worn, rez the HUD, which then asks the owner for permission to attach.   Unless you're using RLV or you are able to use the new Experience Tools, the HUD wil put up a dialog request, asking to attach -- that's pretty much unavoidable -- but at least the user doesn't have to look for a separate HUD in her inventory and then attach it manually.

Is that any use to you?   If it is, I'll gladly help but -- as Rolig says -- we try not to write scripts for people here.   

Share this post


Link to post
Share on other sites

I think thats exactly what i need.  So it's possible that the item held can rez the hud.  Its becoming clearer now.  I'm guessing that is why the product that I saw required that you have rez rights to use the product.  I can use all the help I can get, I am even willing to pay.  But I also want to learn.  Thank you Innula.

Thank you entity0x for the drinking script.

Thank you to everyone who has responded.

Share this post


Link to post
Share on other sites

No need to pay for help in this forum.  

I don't know how much you know about LSL scripting, but LSL is event-driven.   That is, scripts do things when particular events occur -- someone touches the object containing the script, for example, or says something to it,.   You can see all the  available events listed here, in the wiki..

You want to rez a HUD from the cup when someone attaches the cup, so you're going to need the attach event.   This fires when someone wears or unwears an attachment.   

	attach(key id)	{		if(id){			//the avatar whose uuid is represented by id has attached me		}		else{			//no id, so I have just been detached		}	}

So the first step is to get your cup to rez a HUD when someone attaches it.

The function you need to rez things is llRezAtRoot().    This takes 5 arguments:

 llRezAtRoot( string inventory, vector position, vector velocity, rotation rot, integer param );

It may look complicated but it's pretty simple:  Let's look at them in turn.

"String inventory" means the script wants a string value there, the name of the object you want it to rez.   This can be the object's name, or a variable you've declared earlier, or you can even use a function to look up its name at run time,if there's only one object.   You wouldn't normally want to do that each time the function is called, though, since looking up its name each time is pointless if you know the name isn't going to change.

So, llRezAtRoot("My Cup", ...

or 

string strCup = "My Cup";default{	state_entry()	{	}	attach(key id)	{		if(id){			llRezAtRoot(strCup, .....);		}	}}

"Vector position" is where, on the region, you want the object to rez (and it can rez no further than 10 metres away from the object that rezzes it).   You will need to calculate this each time you rez something,since the wearer moves about.   The function that tells you where,on the region, you are is llGetPos().   If you want to rez it at an offset from to llGetPos(), then it's normally llGetPos()+offset * llGetRot().  

The * llGetRot() tells it to use the rezzer's rotatational frame (in this case the wearer's, because that's how LSL works with attachments) rather than the region's, so llGetPos()+<1.0,0.0,0.0> * llGetRot() means "1 metre in front of me" no matter which direction I'm facing, rather than "I metre North of me".     Don't be misled by the * symbol.  In this context it doesn't mean "multiply" (it means "translate by" when applied to a rotation) so the order does matter.   You have to write vector * llGetRot().   llGetRot()*vector means something very different.    

The position at which you rez the object doesn't matter in this particular example, since eventually we want it to move to attach to the wearer as soon it rezzes,  but most of the time it's very important to know how to position objects when they come ouf of the rezzer, so it's good to understand it from the start.   In this example, 1 meter in front of the wearer will be a good place to rez.

"Vector velocity" you can ignore in this context.   It means the speed at which a physical object should be moving when it's rezzed, and you need it when you're making guns and such-like, so the bullets are moving when they appear.   You simply specify ZERO_VECTOR here, since you're not rezzing a moving object.

"Rotation rot" means the rotation at which you want the object to rez.   Since it's a HUD, you don't really need to worry about this, though it's very important when you're rezzing other objects.   In this context, just use llGetRot(), so the HUD rezzes at the same rotation as the avatar is facing (it's going to attach itself to the avatar in a moment, so it's not really important).

"Integer param" is any integer value (whole number) you want to pass to a script in the object you're rezzing.   Typically, you might use it to send the rezzed object the number of a private channel on which the rezzer and the rezzed object can communicate.    You'll probably want to do that here, so just use any convenient number (not 0) for the time being.  Use 99 or something.

Look at the examples in the wiki for llRezAtRoot, and see if you can get the script working, just to rez a box 1 metre in front of you when you attach the cup.  

When you've got that working properly, we can talk about how to make the HUD attach to the avatar wearing the cup once it's rezzed.

Best of luck!

Share this post


Link to post
Share on other sites

Ok, I've tried, but I just don't know enough and I've combed the wiki pages and it's chinese to me.

 

Is there anyone willing to make a simple hud that rez on attached or touch?  I am willing to pay.  If this is the wrong forum to ask just let me know and point me in the right direction.  Please

 

Thank you

Share this post


Link to post
Share on other sites

It is indeed the wrong place, but you gave it a good try.  This is not a difficult task, but one that is slightly above beginner level. You can attract a scripter to write something for you by posting in the InWorld Employment forum. Be sure to pay for a full perm script so you can examine it carefully to see how it works.  Compare it with the example scripts in the LSL wiki for llAttachToAvatarTemp, as I suggested earlier.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...