Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
and use "if" to achive that
if(pause==1) {......}
else {.....}
Wh-whaaat? What's causing the variable to change? How does this even pause a script?This is just a simple If-Then statement. Not really much of a wait script.
But this only works in a step event, and you can only have ONE step event. I want to use a script that allows me to pause a one-frame event script (ie When mouse enters_, since you cannot program that in a step event, at least with DnD, but I also tried doing it with GML, and nothing worked) This engine just can't be convenient for me, can it?
And even if this weren't true, why does it matter? You wouldn't need to set another variable, and a line of code to check the value of that variable. This is unnesicarilly more complex than it has to be. Again, none of this would be necessary if we just had a function that allowed us to pause one event on one sprite for a certain number of frames. Heck, the fact that we can make this code shows that Yoyo games could easilly impliment this code into the language.
It's a very small amount of code. You can toggle the pause variable any way you want. You could make it a button press, mouse over, or any number of other events. Just wrap any code you don't want to occur while the pause is active in an If statement that checks the variable. You can wrap your whole Step event in the If statement if you need to.
The STEP event is what would be refered to as the "event loop" in a standard programming language like C++. All the code written inside of it is created, run, and destroyed every frame (not the same as the screen refresh rate, but based on the same principle). It's intended to be the space where code that is checking for input (internal or external) is identified and acted upon. You can't have more than one per object in GM2 (although the DRAW event is being checked and updated each frame too), but that shouldn't be too limiting.
Objects in Gamemaker are not as general as classes in traditional programming languages, but that is essentially their purpose. They don't have to be "concrete" game elements. Use "abstract" objects (objects with no sprite) to perform logical constructions and interconnectivity between game elements. These "abstract" objects can use their step events to check for conditions and then call the appropriate script when needed (and not call it when you want it "paused").
Scripts, in this software environment, are just supposed to be blocks of code to be called and dismissed as needed by objects (to prevent common blocks from having to be repetitivly typed or complicated inheritance trees). They aren't ment to control the flow of the code; just to be generic code that can be used by multiple objects.
Maybe your difficulty lies in how the script is being called in the first place. You keep insisting that ypu need the script to be "paused" under certain circumstances. This makes me think you are using them in a way that wouldn't work well in this software package because scripts shouldn't be "on" unless specificly called. Wouldn't it be easier to "pause" the script by setting up a conditional statement so that, under the circumstances of your needed "pause", it just isn't called?
As a side note (but very much related) are you making sure that variables that need to be maintained (not destroyed and recreated each step) are attached to an object that calls the script? Just like variables that are created (declared) in the STEP event instead of the CREATE event, variables created inside of a script are created and destroyed and recreated every time the script is called. Since the STEP event is typically occuring between 30 and 60 times per second (as per the user setting), your code archetecture needs to take this into consideration. An instance of an object maintains its CREATE event variables until it is explicitly destroyed, but the STEP, DRAW, and any other "event" that is essentially a "loop" within the object will be constantly reset each cycle. This is another reason not to use scripts in GM2 as something that is intended to be "on" all the time.
I sincerely hope this helps
Increment the first variable from some step event from ONE object (preferrably the single instance of a control object you have), do try to not have it run over its max.
or, a more safe version that requires knowing nothing...
Both of those will make sure the code inside the if-statement dont run for the specified amount of frames.
If you just need a flag, the first commenter's thing will do.
If you dont understand how it works, stop using GMS and go learn to program. Pick an object-oriented language like Java. Come back after that and a measly little if-statement will be one of the least complicated things you do