Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

HuD Question

Ruboneout Shoreman
Registered User
Join date: 29 Jul 2009
Posts: 38
01-19-2010 23:14
I want to start out by saying that I am no where close to being a good scripter but I was trying to put together a rez HuD and I have come across a question. I was going to simply put a script in each button on the hud, and when pressed, it would rez an object. Would this be an O.K idea? I know I can do it this way, but I was concerned sim lag and everything else. I would like to get into the habit on doing things the most efficient way that I can. With this being said, is it possible to name all of the buttons like platform,cube,chair,house, etc... so when you click on the button, since it will be linked to the main part of the HuD, the HuD can rez the appropriate item based on the NAME of the button that was clicked? This way, I don't have scripts in every single button on the HuD. If this is possible, could anyone lead me in the right direction? Thank you.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-19-2010 23:44
yes very possible.... you don't even need to use names,.. in fact you don't need multiple button prims...


these functions should help
with button prims
https://wiki.secondlife.com/wiki/LlDetectedLinkNumber - for prim number touched
https://wiki.secondlife.com/wiki/LlGetLinkName - for name from link number

or with a texture image that has buttons painted on
https://wiki.secondlife.com/wiki/LlDetectedTouchFace - for the prim face touched
https://wiki.secondlife.com/wiki/LlDetectedTouchST - for the position on the prim face touched
https://wiki.secondlife.com/wiki/LlDetectedTouchUV - for position of the texture on the prim face touched
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Twisted Pharaoh
if ("hello") {"hey hey";}
Join date: 24 Mar 2007
Posts: 315
01-19-2010 23:46
There are ways to communicate with the prims but you could have just one prim and use llDetectedTouchST instead:

http://wiki.secondlife.com/wiki/LlDetectedTouchST

(hehe, Void beat me to it)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-19-2010 23:48
Muahahaha, the all seeing eye ... er... sees all?
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Ruboneout Shoreman
Registered User
Join date: 29 Jul 2009
Posts: 38
01-19-2010 23:53
Wow..... I have SO much to learn. Thank you very much for the continued help, and all of the information! :D
Ephraim Kappler
Reprobate
Join date: 9 Jul 2007
Posts: 1,946
01-19-2010 23:54
There is no need for a script in each prim. You can use llDetectedLinkNumber to detect which 'button' in the prim has been touched like so:

CODE

if (llDetectedLinkNumber(0) == 2) // Where 2 is the number of the linked prim
{
... do something ...
}


The number of a linked prim is determined by the reverse order in which it has been linked to the set of prims in the object. The first prim to be linked in a set of six will be 6, for instance. Drop this little script in a prim if you have a very large or complex object where it is difficult to count the linking order:

CODE

default
{
state_entry()
{
llOwnerSay("The link number of this primitive is " + (string) llGetLinkNumber());
}
}


There are other useful functions such as llDetectedTouchFace that allow you to choose a particular face on a prim. When used with llSetLocalRot to rotate the prim 'button', any number of faces on the prim can be dedicated to a different function of the script.

Also you could use llDetectedTouchUV to differentiate areas on the same texture on a single prim for different functions.

ETA: Void and Twisted (great name) beat me to it. I must check out llDetectedTouchST myself. Of course I forgot about llGetLinkName - I find it easier to work with prim numbers rather than worry about naming prims. I'll leave the code examples anyway. You will find the prim number script handy.
Ruboneout Shoreman
Registered User
Join date: 29 Jul 2009
Posts: 38
01-20-2010 00:10
With all of this information I am pretty confident that I can easily accomplish this now! Thanks for the help. I have one more question though, if you don't mind. I wanted to my make my HUD expandable, and collapsible. With that in mind, could anyone point me in the direction of when I press 1 button, all of my prims that make up the HuD move together?
Ephraim Kappler
Reprobate
Join date: 9 Jul 2007
Posts: 1,946
01-20-2010 02:32
llSetLocalRot or maybe llSetRot is your friend. You can try both and see which works best (I'm not an expert scripter).

Make the main HUD prim really shallow along the top or narrowest side adjacent to the edge of the monitor screen. Normally that face will be invisible when the HUD is 'worn' on the monitor screen in an active state.

Dedicate a button on the HUD to 'collapse' it by rotating to show that face and set the touch event on that face to rotate the HUD back to its normal view.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
01-20-2010 07:20
You will also find you simplify life for yourself no end if you build the hud so that the main face (the one that presents itself by default when you attach the hud) is -- assuming the prim is based on a standard cube -- on face 4 of the prim. That is, the side with the red arrow running into it when the prim is first rezzed (or anytime you're looking at it in local ruler mode).

That means the default rotation is ZERO_ROTATION, so you don't need to worry about offsetting it, and it should show up correctly no matter what the user's screen resolution might be.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-20-2010 08:14
to elaborate on Ephraim's example, you'd use two different faces of your hud prim, shaped a bit like a sheet cake box, the expanded hud would be on the larger face, and the collapsed hud would be on the thinner face. llDetectedTouchFace will tell you which version is being used (collapsed or expanded).

I'd also recommend using llDetectedTouchUV in this case, since it orients to the image rather than the prim (and remember that y is measured bottom up, unlike most image apps which y is top to down)

there are formulas to capture button press locations on an image in this thread:
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
01-24-2010 13:50
From: Ruboneout Shoreman
I want to start out by saying that I am no where close to being a good scripter but I was trying to put together a rez HuD and I have come across a question. I was going to simply put a script in each button on the hud, and when pressed, it would rez an object. Would this be an O.K idea? I know I can do it this way, but I was concerned sim lag and everything else. I would like to get into the habit on doing things the most efficient way that I can. With this being said, is it possible to name all of the buttons like platform,cube,chair,house, etc... so when you click on the button, since it will be linked to the main part of the HuD, the HuD can rez the appropriate item based on the NAME of the button that was clicked? This way, I don't have scripts in every single button on the HuD. If this is possible, could anyone lead me in the right direction? Thank you.


I just made a HUD to do this using this Inventory Based Menu script. It compiles a menu of everything in the objects inventory and presents it to you when touched.

http://wiki.secondlife.com/wiki/Inventory_Based_Menu?
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo