Create/remove overlay when GUI is off/on (SOLVED!)

Started by Oz, Tue 23/11/2004 21:40:51

Previous topic - Next topic

Oz

Hey,

I have a text overlay on top of the screen that I want to disappear whenever the iconbar GUI is visible (otherwise they overlap and things get messy). How would I go about doing this? I tried this:

// in the script header:

int location;

// in 'after fadein':

if (IsGUIOn(3)==1){
location=CreateTextOverlay(130,10,100,0,65503,"text");
}

if (IsGUIOn(3)==0){
RemoveOverlay(location);
}

When I try this I get an "invalid overlay id passed" error message.

Should the part removing the overlay go in 'repeatedly execute'? If so, how do I prevent the overlay to
be created over and over again until the limit of created overlays is reached?

The main problem seems to be the "invalid overlay id" though.
Diversity is divine!

Pumaman

The "after fadein" event is only run once, when the player enters the room.

Therefore, that code will create the overlay if the icon bar GUI is visible when the player enters the room, and attempt to remove it otherwise. Attempting to remove it will fail since it was never created, which will give you an error.

The best approach is probably to just have the CreateTextOverlay line in the After Fadein event, and then do something like this in repeatedly_execute:

if ((IsGUIOn(3) == 1) && (IsOverlayValid(location))) {
  RemoveOverlay(location);
}
else if ((IsGUIOn(3) == 0) && (!IsOverlayValid(location))) {
  location=CreateTextOverlay(130,10,100,0,65503,"text");
}

strazer

Or you could move the overlay in and out of the screen bounds with MoveOverlay to avoid having to create it again.

Oz

Diversity is divine!

Pod

What function is called when the gui rolls down?

SMF spam blocked by CleanTalk