Jump to content

HUD to toggle an attachment.


Kaitopt
 Share

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

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

Recommended Posts

Hi everyone. I'm new to LSL and scripting. I want to make a single button HUD that simply toggles the alpha of a prim attachment I created. To be clear, this attachment is made up of 5 prims and want a button to hide it and reveal it each time I click it. Thank you in advance.

Link to comment
Share on other sites

Quite simply, your attachment needs a script that toggles alpha when it hears a signal from the HUD:

default
{
     state_entry()
     {
          llListen(my_channel,"","","");
     }

     listen(integer channel, string name, key id, string message)
     {
          if (message == "on")
          {
               llSetLinkAlpha(LINK_SET, 1.0,ALL_SIDES);
          }
          else if (message == "off")
          {
               llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
          }
     }
}

And your HUD needs to send a message when you click it:

integer iOn;

default
{
     touch_start(integer num)
     {
          llSay(my_channel,llList2String([ "off", "on" ], (iOn = !iOn) );
     }
}

Just be sure that you give my_channel the same value in both scripts.

  • Like 1
Link to comment
Share on other sites

Welcome to the forums and to LSL scripting!

HUDs are one of the hardest things to script well in LSL. But for something this simple it should give you a good entry point :)

the first thing to know about HUDs is that they can't really do much to things in world (with a few fun notable exceptions) and generally speaking objects don't do things to other objects, they tell the objects to do things to themselves.

Part 1. Making a HUD.

HUDs are just like any other object, but you wear them in front of your face. so create a prim take it into your inventory and wear it as a HUD (details vary depending on viewer), then add a script like so:

@Rolig Loon beat me at typing; see her post.

then add a script that listens on the same channel to your object

See Rolig's example

Quite simple really.

 

Edited by Quistessa
added grammar.
Link to comment
Share on other sites

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