VeranniCakes Posted January 31, 2021 Share Posted January 31, 2021 Hello, I need help with this script pls, I'm a beginner but I know a little bit about coding. I'm trying to turn on a light with a hud, but the light isn't turning on. Here is my code. //This is the HUD script //This is a simple Light Hud, turning a Light on and off. //The light source is on an object called GlowStick, The HUD is called Glowstick HUD //PRIM_POINT_LIGHT is being used No PRIMGLOW codes //Channel being used is 100 integer switch; integer ONButton = 2; integer OFFButton = 3; default { state_entry() { } touch_start(integer total_number) { integer press = llDetectedLinkNumber(0); if(press == ONButton) { llOwnerSay("ON Button"); llRegionSayTo(llGetOwner(),100,"ON Button Connected"); llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <0.2, 0.8, 0.8>, 1.0, 10, 0.75 ]); } else if(press == OFFButton) { llOwnerSay("OFF Button"); llRegionSayTo(llGetOwner(),100,"OFF Button Connected"); llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <0.2, 0.8, 0.8>, 1.0, 10, 0.75 ]); } } } _____________________________________________________ //Glowstick Object default { state_entry() { llListen(100,"Glow Stick HUD","",""); } listen(integer channel, string name, key id, string message) { if(llGetOwnerKey(id) != llGetOwner() ) return; else llOwnerSay(message); } } Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted January 31, 2021 Share Posted January 31, 2021 (edited) You've sort of got it, you just mixed something up. In your HUD script, you're correctly using llRegionSayTo, to send a message to your attachments on channel 100. But then, you're enabling PRIM_POINT_LIGHT in the HUD itself, which won't work since HUDs cannot emit light. Meanwhile, your glowstick script isn't really doing anything. It's listening to messages and simply repeating them back to you. The glowstick script should check which message it received and enable PRIM_POINT_LIGHT instead of the HUD. default //Glowstick Object { state_entry() { llListen(100,"Glow Stick HUD","",""); } listen(integer channel, string name, key id, string message) { if (llGetOwnerKey(id) != llGetOwner()) return; else if (message == "ON Button Connected") { llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <0.2, 0.8, 0.8>, 1.0, 10, 0.75 ]); } else if (message == "OFF Button Connected") { llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <0.2, 0.8, 0.8>, 1.0, 10, 0.75 ]); } } } I think it's also important to point out that you should do your best at keeping the indentation consistent, so you can easily see where the curly-brace pairs are. It's much harder to find mistakes when they're all over the place or not indented at all. Edited January 31, 2021 by Wulfie Reanimator 1 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 31, 2021 Share Posted January 31, 2021 (edited) Both of the llSetPrimitiveParams statements belong in the object that lights up. not in the HUD. The HUD just sends a message to the light. The light does the actual lighting. Just think through the logic. You've got it mostly right, just in the wrong object. If you want to be mildly more sophisticated, there are better ways to build a HUD than with separate ON/OFF buttons, but the way you are doing it will work just fine. Hehe ... What Wulfie just said ^^.. He types faster than I do. 😃 Edited January 31, 2021 by Rolig Loon 2 Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted January 31, 2021 Share Posted January 31, 2021 2 minutes ago, Rolig Loon said: Hehe ... What Wulfie just said ^^.. He types faster than I do. 😃 She 💖 1 Link to comment Share on other sites More sharing options...
VeranniCakes Posted January 31, 2021 Author Share Posted January 31, 2021 Ok! wow oof! Thank you!! and for replying thks. That's what I did wrong?! I just putting the SetPrimitiveParams in the wrong object? lol I was thinking it was the Hud that will do all the work lol, Ok I will indent my braces more and aline them better. Link to comment Share on other sites More sharing options...
VeranniCakes Posted January 31, 2021 Author Share Posted January 31, 2021 If you want to be mildly more sophisticated, there are better ways to build a HUD than with separate ON/OFF buttons, but the way you are doing it will work just fine. _________________________________________________________________________________________________________________________________________________________________ Yeah It's an easy project, I'm a beginner. I guess it can pass as sophisticated, thanks lol. 1 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