Jump to content

need help show/hide


walterwhiteSr
 Share

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

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

Recommended Posts

Hi, just getting started in using scripts in objects..

I have a show/hide script that works fine on chat channel

I would like to make this script show/hide the object when another object is touched (a switch), I have looked for examples but can't seem to find anything that would either check the current state show or hide and then when touch/switch it goes to the other state.

default
{ 
    state_entry()
    {
        llListen(90, "", NULL_KEY, "");
    }

    listen(integer channel, string name, key id, string message)
    {
        if (message == "show") llSetAlpha(1.0, ALL_SIDES); 
        else if (message == "hide") llSetAlpha(0.0, ALL_SIDES);
        else return;
    }
}

 

 

Link to comment
Share on other sites

Currently your script is configured to listen to text-chat input. When it hears 'show' it will show, 'hide' will hide.

That's fine for this script.

--

To have a touch-enabled script in another object, you'll need to use the touch or touch_start event in a new script inside that object.

You'll also need a toggle switch, a variable that alternates between two values (such as TRUE and FALSE, or 1 and 0).

Remember that this variable will need declaring as a global variable at the top of your script.

Then a small piece of toggle code, such as:-

if(iSHOWN == TRUE){
//IF TRUE, SET FALSE llSay(90,"show"); iSHOWN = FALSE;}else{
//ELSE IF FALSE, SET TRUE llSay(90,"hide"); iSHOWN = TRUE;}

The value of iSHOWN will alternate each time this code is called. TRUE will become FALSE, and FALSE will become TRUE.

The function llSay will communicate to the first object that it should hide or show, provided it is within 20m (the range of 'say' chat, vs. shout or regionsay).

Link to comment
Share on other sites

This script should work as a sim-wide switch for your script:

 

integer toggle;

default
{
     state_entry()
     {

     }

     touch_start(integer total_number)
     {
         if (!toggle)
         {
               toggle = TRUE;
               llRegionSay(90, "show");
         }
        else if (toggle)
       {
              toggle = FALSE;
              llRegionSay(90, "hide");
        }
    }
}

Link to comment
Share on other sites

// and the inline version ...

integer tog;

default
{
     state_entry()
     {
     }

     touch_start(integer total_number)
     {
         if (tog = !tog)
          llRegionSay(90, "show");       
        else
           llRegionSay(90, "hide");
    }
}

Link to comment
Share on other sites

Sorry took a little time to get back..  Thanks to all who replied..  I used only  Rolig Loon's version, it works perfect!

Will Test the other examples too just to learn.. much appreciated...  Will report if any have issues, so correction can be offered to help another noob as myself..

 

edit,

all versions worked!!!!

thanks again!

Link to comment
Share on other sites

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