Jump to content

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 post
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 post
Share on other sites
Posted (edited)

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 post
Share on other sites

Thank you so much for the help. I learned about HUDs being objects back in the poseball days using root prims to make "pose anywhere" HUDs lol.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...