Kaitopt Posted May 10, 2021 Share Posted May 10, 2021 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 More sharing options...
Rolig Loon Posted May 10, 2021 Share Posted May 10, 2021 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. 1 Link to comment Share on other sites More sharing options...
Quistess Alpha Posted May 10, 2021 Share Posted May 10, 2021 (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 May 10, 2021 by Quistessa added grammar. Link to comment Share on other sites More sharing options...
Kaitopt Posted May 11, 2021 Author Share Posted May 11, 2021 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 comment Share on other sites More sharing options...
Recommended Posts
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