Jump to content

Noob issue with flow control.


Tomko Galicia
 Share

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

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

Recommended Posts

I'm trying to add a show/hide option to a dialog menu. The problem I have is when I press the button, it works, then brings back the menu. However when I click the button again it won't action the second if statement and closes the menu. When I reclick the menu the button works again.

 

The code I'm using is 

 

if (message == "Show/Hide")
{
if (show == 0)
{
show = 1;
llSetAlpha(0.0, ALL_SIDES); // set entire prim 100% invisible.
}

else
{
show = 0;
llSetAlpha(1.0, ALL_SIDES); // set entire prim 100% visible.
}

llDialog(ToucherID, dialogInfo, buttons, dialogChannel);
}

Link to comment
Share on other sites

My guess is that you haven't made "show" a global variable.  If it's local to this part of the script, then you are setting it to equal 1 inside your first test and then forgetting it.  If you make "show" glbal, though, it will remember that value the next time you need it.

Having said that, there's a much simpler way to write that section of code (again, assuming that "show" is a global integer)...

if (message == "Show/Hide"){    llSetAlpha(1.0 * (show = !show), ALL_SIDES);    llDialog(ToucherID,dialoginfo, buttons, dialogChannel);}

 

 

 

  • Like 1
Link to comment
Share on other sites

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