Jump to content

Creating a HUD?


MuffinUnsane1488303563
 Share

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

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

Recommended Posts

I'm a bit stumped on a small project of mine.

 

I've made a tongue and wanted to have a HUD for it. Just a simple touch and the tounge goes invisiable with a texture change. Another touch and it becomes visible. Since its for personal use I don't want anything fancy.


Is there a site or tutorial that I can learn from? I've tried those automatic script makers but none seemed to be able to do what I want. I've tried googling a bit but nothig has turned up.


Much thanks for reading!

Link to comment
Share on other sites

If I understand you right, what you need to know is how to let two scipts communicate. This aspect is, as far as I remember, not reaqlly covered in the two tutorials.

 

Basically, you need te commands llSay (others are possible as well - but let's keep it simple for a start. (And yes, llRegionSay would be preferable) )- llListen and a listen event.

If you follow the links and read up, I'm sure you get a pretty good idea of how to do it. If you still got questions  - just came back

Link to comment
Share on other sites

I think I would use llRegionSayTo(llGetOwner(), channel, "message") for a hud.   It's no more complicated than llSay(channel, "message") and it avoids lots of potential problems.   The great thing about llRegionSayTo(an avatar, channel, "message") is that the avatar's attachments (and only the avatar's attachments, assuming the channel isn't 0) can hear it if they're listening on the right channel.    It's also slightly kinder on the sim.

For the simple mechanism you describe, you might need to know how to make a basic on/off switch (which baffled me for ages when I started scripting)

 

integer toggle;//simple integer, 0 by defaultdefault{	state_entry()	{		//llSay(0, "Hello, Avatar!");	}	touch_start(integer total_number)	{		toggle =!toggle;//switch the value of toggle between 0 and 1 each time I'm touched		if(toggle){			//do something		}		else{			//do something different		}	}}

 The other bit of advice about huds that I find invaluable is always to make the main face (the one you can see when wearing it) side 4 of a standard box -- that is, the side the red arrow goes into when first you rez the prim.   If you don't do that, you will assuredly dissolve into tears of rage and frustration at some point when trying to get it to face the right way when attached.

Link to comment
Share on other sites

Thank you all for the links. : )

 

I've looked into it and managed to at least gleam some of the stuff. I've got the HUD set up and its just mostly the scripts. I found the script for changing the alpha of an object. Also looked up on the 'listen' and say 'aspects'. The main trouble I'm having now is just linking them. I've tried looking for examples in the avatars I have but no luck.


Looking into it there seems to be one script for listen/alpha and one for say?


I'm so sorry if this is making things more confusing.

Link to comment
Share on other sites

I used the script above to get the alpha to work on touch.


MuffinUnsane wrote:

integer toggle;//simple integer, 0 by default

default

{

    state_entry()

    {

        //llSay(0, "Hello, Avatar!");

    }

    touch_start(integer total_number)

    {

        toggle =!toggle;//switch the value of toggle between 0 and 1 each time I'm touched

        if(toggle){

             llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES); //do something

        }

        else{

             llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);//do something different

        }


    }

}


So really, the only trouble I am having is a listener script in the HUD prim. Looking at the wiki for Listen it seems to list one that is for chat uses. So, would it be changing Ownersay to something about touch?


Again, thank you for all the help. I'm sorry for being so slow to catch up.

Link to comment
Share on other sites

No worries.  You are doing very well.

Don't be confused, though, with llOwnerSay().   That's used to make things appear in local chat for the owner of the object but no one else.  It's very useful, of course, for cutting down on spam, but it's not what we want here.  

You need to use llRegionSayTo(key, channel, message).   This is because, if the key is that of an avatar then any attachements the avatar is wearing can hear the message, so long as they are listening on the right channel.   And other people's attachments, or other objects, can't.  

So you need the hud to say "show" or "hide", and the tongue object to listen on the right channel and behave accordingly.

For the hud, I would do it this way:

 

integer secret_channel = -13745; // choose any number you wantinteger toggle;key owner;//declare a varible to store the owner's uuid, since it's pointless checking who the owner is each timedefault{    attach(key attached)    {        if(attached){//each time I'm attached            owner = attached;//can only wear things that belong to you, so store the wearer's uuid            toggle = FALSE;            llRegionSayTo(owner,secret_channel,"hide");//start off hiding stuff        }    }    touch_start(integer total_number)    {        toggle = !toggle;        if(toggle){            llRegionSayTo(owner,secret_channel,"show");        }        else{            llRegionSay(owner,secret_channel,"hide");        }    }}

 and then for the tongue you need something like this

integer secret_channel = -13745; // same number the hud usesinteger handle;key owner;//declare a varible to store the owner's uuid, since it's pointless checking who the owner is each timedefault{	attach(key attached)	{		if(attached){			//do something to hide the tongue			llListenRemove(handle);//remove and reset the listener.. probably not necessary but good practice			handle = llListen(secret_channel,"","","",);//start listening on the same channel the hud uses		}	}	listen(integer channel, string name, key id, string message)	{		if(llGetOwnerKey(id)==owner){//just about inconceivable that it won't be a message from anything that doesn't belong to the owner, but best to check			if("show"==message){				//do something to show the tongue			}			else if ("hide"==message){				//do something to hide the tongue			}		}	}}

 

  • Like 1
Link to comment
Share on other sites

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