Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gepard on Sat 03/01/2009 16:40:34

Title: gui wont show up + int (max. amount)
Post by: Gepard on Sat 03/01/2009 16:40:34
I have a gui with a button on it. This gui will pop up mouse Y pos 5. Script for the button:

  PlaySound (6);
  gGui5.Visible = false;
  gMain.Visible = true;

First time I move my mouse to the top of the screen, gGui5 shows up as it should. Now after I click the button, gGui5 turns off as it should and gMain shows up as it should. But when I close gMain and try to popup gGui5 by moving the mouse to the top of the screen than gGui5 wont show up. I also have another button on that gui with a different function, but the result is the same. I press the button it never shows up again. Where is the problem?   :'(

PS: If I dont press any button, its ok with gGui5.

(my ags version 2.72)
Title: Re: gui wont show up
Post by: on Sat 03/01/2009 17:04:46
I think it's because you need to reset gGUI5 to "visible"- you either need a button on your popup GUI for that (just enter gGui5.Visible = true) into it's on_click, or you need to check in repeteatly_execute if the cursor has left the popup GUI. As you describe it your GUI actually TURNS UP the next time you click, but you can't see it ;)
Title: Re: gui wont show up
Post by: Gepard on Sat 03/01/2009 18:12:15
Oh yeah... yeah! That did it. But it really gave me headaches. Thanks a lot.
Title: Re: gui wont show up
Post by: on Sat 03/01/2009 19:06:14
It's these tiny snares that make AGS such a loveable bitch ;)
Title: Re: gui wont show up
Post by: Gepard on Sat 03/01/2009 22:19:27
 ;D True! Im always so angry when something is not working and I dont know why... but than Im so happy it finally DOES work!

Btw. another thing, but I dont wanna post a new thread: I have an int, lets say its health. And if my char. goes to sleep, he can recover say 200 of his health, thing is, I dont want him to recover more than a certain level of health, say 1000. How do I do that?
Title: Re: gui wont show up + int (max. amount)
Post by: on Sat 03/01/2009 23:21:01
...add health like this


health+=(whatever);


and then:


if (health > 1000) {
  health = 1000;
}


Even neater is something like this:

Top of global script:

int maxHealth = 1000;
int sleepHealthBonus = 200;


And then make your own function:

function Sleep() {
  health+=sleepHealthBonus;
  if (health > maxHealth) {
    health = maxHealth;
  }


Import this in the header by typing:

import function Sleep();

there, and you can call it from all room scripts you want. All you do is type "Sleep()".

You could also use DEFINES for the max values, and some might also suggest to make Sleep an extender
function, but this should already get you started ;)