Jump to content

Show / hide objects by HUD Script


MIVIMEX
 Share

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

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

Recommended Posts

Hello! Please help to make a script for three button HUD to make one of the objects in the linkset visible. 

Thanks for any help!

Im noob to scripting and already posted at wanted too, please pardon for double post!

Very needed!

Link to comment
Share on other sites

By now, you know that we are not likely to provide full scripts here in the LSL Scripting forum, except as rough examples, so you are most likely to get a good response from your post in the Wanted or InWorld Employment forums.  If you are planning to write your own script, though, all you need to do is have each HUD button trigger a unique message to whatever you are trying to control.  Then, provide the object that you want to control with a script that says, "When you hear the message '1', become visible.  When you hear the message '0', disappear." Send the message with llRegionSayTo, aimed at the specific object that you want to control, or include something in the message that can only be understood by that object.

  • Thanks 1
Link to comment
Share on other sites

16 minutes ago, Rolig Loon said:

By now, you know that we are not likely to provide full scripts here in the LSL .

Do I understand correctly that two scripts are needed: for the object and for the HUD?
I'm afraid of HUDs like fire! I know it too much but can you give a simple example? Please!

Link to comment
Share on other sites

A HUD is not a special object.  It is like any other object that you script.  In fact, it's usually easiest to write and test a HUD by building your script in  prim on the ground.  Just make your script say something when you click on it.  Then write a script in some other object to listen for that message and do something when it hears the message. It's no more difficult than that.

Edited by Rolig Loon
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

13 hours ago, Rolig Loon said:

A HUD is not a special object.  It is like any other object that you script.  In fact, it's usually easiest to write and test a HUD by building your script in  prim on the ground.  Just make your script say something when you click on it.  Then write a script in some other object to listen for that message and do something when it hears the message. It's no more difficult than that.

Hello! I was given two such scripts for HUD and for objects. But they do not work exactly the way I want. Could you help me fix them? The click on a button makes the object visible and the second button invisible. But I need that when you click on a certain button, the selected object in the link set becomes visible and the other two are invisible. If you are interested please let me know. Thank you so much.

 

HUD

integer numberOfColumns = 1;
integer numberOfRows = 3;
integer currentCellNumber;
default
{
    on_rez(integer rez)
    {  if (!llGetAttached() )    
       llResetScript();      
    }
    state_entry()
    {  llSetScale(<0.03, 0.15, 0.15>);       
       llSetObjectName("HUD test 4");  
       llSetLinkPrimitiveParamsFast(LINK_THIS,
         [  PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 1.0,
            PRIM_TEXTURE, ALL_SIDES, "5748decc-f629-461c-9a36-a35a221fe21f", <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0,
            PRIM_TEXTURE, 4, "ac6b1c32-509c-eb96-107c-cc378669d8fd", <1.0, 3.0, 0.0>, ZERO_VECTOR, 0.0, 
            PRIM_LINK_TARGET, LINK_THIS,
            PRIM_COLOR, 4, <0.0, 1.0, 1.0>, 1.0]);
            
       llRequestPermissions( llGetOwner(), PERMISSION_ATTACH );  
    }    
    run_time_permissions( integer vBitPermissions )
    {  if ( vBitPermissions & PERMISSION_ATTACH )     
       {  llAttachToAvatar( ATTACH_HUD_TOP_CENTER );
          llSetPos(  <0,0,-0.1>); 
       } 
       else     
       llOwnerSay( "Permission to attach denied" );
    }
    attach(key id)
    {  if (id)
       { llOwnerSay( "The object is attached. ");
         llSetPos(  <0,0,-0.1>);   
         llReleaseCamera( llGetOwner() );
       }
       else 
       {  llOwnerSay( "The object has been detached");
       }
    }  
    touch_start(integer total_number)
    { 
       integer face =   llDetectedTouchFace(0); 
       vector touchST = llDetectedTouchST(0);        
        if (face == -1)
            llInstantMessage( llGetOwner(), "Sorry, your viewer doesn't support touched faces. Please update it!");
        else if (touchST == TOUCH_INVALID_TEXCOORD)
            llInstantMessage( llGetOwner(),"Sorry, a touch position could not be determined.");
        else if (face != 4)
            llInstantMessage( llGetOwner(),"Please touch the front!");   
             
        else  //we flip vertically and calculate a cell number
        {   currentCellNumber = llFloor(touchST.x*numberOfColumns) +
            (numberOfRows -llCeil(touchST.y*numberOfRows))*numberOfColumns + 1; 
        }
        if( currentCellNumber == 1)
        {   llRegionSay( -25,"invis" );
        }
        if( currentCellNumber == 2)
        {   llRegionSay( -25,"vis" );
        }
        if( currentCellNumber == 3)
        {
        }
    }
}

LINK SET

default
{
    state_entry()
    { llListen(-25, "", "", "");
    }   
    listen(integer channel, string name, key id, string message)
    { if( message == "invis")
      {  llSetLinkAlpha(LINK_THIS, 0.0, ALL_SIDES);
      }
      if( message == "vis")
      {  llSetLinkAlpha(LINK_THIS, 1.0, ALL_SIDES);
      }
    }
}

 

Edited by MIVIMEX
Link to comment
Share on other sites

4 hours ago, MIVIMEX said:

But I need that when you click on a certain button, the selected object in the link set becomes visible and the other two are invisible.

You should try sending messages like "vis1", "vis2", "vis3" from the HUD and then check which of those messages was received in the target object.

Rough example so you can have some practice:
If "vis1", llSetLinkAlpha(link1, visible), llSetLinkAlpha(link2, invisible), llSetLinkAlpha(link3, invisible)

Edited by Wulfie Reanimator
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Wulfie Reanimator said:

 

If "vis1", llSetLinkAlpha(link1, visible), llSetLinkAlpha(link2, invisible), llSetLinkAlpha(link3, invisible)

Wow! Thank you so much! Two heads is better than one! So thats what I got but it says: name not defined (link1,2,3) How do i define this names?

default
{
    state_entry()
    { llListen(-25, "", "", "");
    }   
    listen(integer channel, string name, key id, string message)
    { if( message == "vis1")
      {  llSetLinkAlpha(link1, 1.0, ALL_SIDES);
         llSetLinkAlpha(link2, 0.0, ALL_SIDES);
         llSetLinkAlpha(link3, 0.0, ALL_SIDES);
      }
      
      if( message == "vis2")
      {  llSetLinkAlpha(link1, 0.0, ALL_SIDES);
         llSetLinkAlpha(link2, 1.0, ALL_SIDES);
         llSetLinkAlpha(link3, 0.0, ALL_SIDES);
      }
      
      if( message == "vis3")
      {  llSetLinkAlpha(link1, 0.0, ALL_SIDES);
         llSetLinkAlpha(link2, 0.0, ALL_SIDES);
         llSetLinkAlpha(link3, 1.0, ALL_SIDES);
      }
    }
}

 

Please help!

Edited by MIVIMEX
Link to comment
Share on other sites

1 hour ago, pixstudio said:

you want to use a single script in hud?

if you use a multi script sistem you can solve easily this problem

bt 1 texture transmitter (uuid of texture)

bt  2 texture transimitter (uuid Alpha texture)

 

 

Hello! Thanks for responce! Yes it can be a multiscript, but what is texture transmitter? Tell me please?

Link to comment
Share on other sites

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