I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: BoshyMan741 on December 07, 2014, 08:14:00 PM

Title: Making an object show only once?
Post by: BoshyMan741 on December 07, 2014, 08:14:00 PM
Does anyone here know how to make objects only appear once. (In Gamemaker 8.1) Kinda like the warnings in Happil 2 how they only appear once until you reset/press esc. No one on skype knew how.  :BibleThump:
Title: Re: Making an object show only once?
Post by: pieceofcheese87 on December 07, 2014, 09:38:17 PM
Make it a persistent object. Have it become invisible instead of destroying itself, and it destroys itself on the room end event
Title: Re: Making an object show only once?
Post by: Sephalos on December 07, 2014, 11:03:08 PM
Global variables would do the trick. Simply do something similar to this.

Code: [Select]
If global.warning[1] = 0 {
      // put your warning script here
      global.warning[1] = 1;
}

Global variables are persistant until you close or reset the game (or until you reset them to 0 manually). The number 1 within the square brackets can be changed so you can have many different warnings in your game.
Title: Re: Making an object show only once?
Post by: BoshyMan741 on December 07, 2014, 11:53:16 PM
Thank you!  :BloodTrail:
Title: Re: Making an object show only once?
Post by: BoshyMan741 on December 08, 2014, 01:22:36 AM
Oops... By reset I meant as in pressing F2 not R. Is there a way to change it?
Title: Re: Making an object show only once?
Post by: Stepcore on December 08, 2014, 03:10:40 AM
If it shows every time you press R it's because you manually set it to 0 in that room or it's not global.
Title: Re: Making an object show only once?
Post by: Sephalos on December 08, 2014, 03:04:43 PM
If your global variables are reseting to 0 when you press "R" you might be having a problem with the engine.

Check the load scripts and make sure the game doesn't have a restart_game in there. If you do that however, you might have other problems with global trigger variables wich you will need to set to 0 when pressing "R". (before the loadGame script is executed)
Title: Re: Making an object show only once?
Post by: BoshyMan741 on December 08, 2014, 07:00:40 PM
Yep that was the problem too.  :tenKapple: I fixed the other global variables too. Thanks.  :atkHappy: