gui wont show up + int (max. amount)

Started by Gepard, Sat 03/01/2009 16:40:34

Previous topic - Next topic

Gepard

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)
Drink up me 'arties! Yo ho!

Ghost

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 ;)

Gepard

Oh yeah... yeah! That did it. But it really gave me headaches. Thanks a lot.
Drink up me 'arties! Yo ho!

Ghost

It's these tiny snares that make AGS such a loveable bitch ;)

Gepard

 ;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?
Drink up me 'arties! Yo ho!

Ghost

#5
...add health like this

Code: ags

health+=(whatever);


and then:

Code: ags

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


Even neater is something like this:

Top of global script:
Code: ags

int maxHealth = 1000;
int sleepHealthBonus = 200;


And then make your own function:
Code: ags

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


Import this in the header by typing:
Code: ags

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 ;)

SMF spam blocked by CleanTalk