GameMaker Studio 2 Desktop

GameMaker Studio 2 Desktop

Robablo Jan 2, 2018 @ 2:24pm
Why is there no WAIT script?
I need to be able to pause a specific script for a certain number of frames, but there seems to be no way of doing that in GMS2 without a step event and way too much coding. I just want to be able to pause a "Alarm OFF" event, because otherwise "Repeat" scripts just repeat the code however many times I set it to loop in one frame. A wait script would simplify this whole process, but from what I read, Yoyo games is just too inept to be able to do that, despite the fact that I can't think of another coding language that did this. Apparently the old script paused the whole game and really bothered certain OSes, but one, Why can't you just make it pause the current script, like ALMOST EVERY OTHER ENGINE IN EXISTANCE, and two, if your program is messing with OSs just by pausing, youre really bad at coding pauses. In whatever fashion this engine was made, I cannot think of a single reason why they couldn't add a wait script in. And because of this, making the games I want to make will now be unecissarilly more complicated, difficult, and overbearing.
< >
Showing 1-11 of 11 comments
just set a variable(just like "pause") to tell whether looping or not
and use "if" to achive that
if(pause==1) {......}
else {.....}
MrDave Jan 3, 2018 @ 4:42am 
I think anyone else would have just asked how to do it rather than going off on a massive rant at YoyoGames. It really isn’t hard to do and you just show everyone who the inept programmer is. No one wants to help someone with a comment like this .
Robablo Jan 4, 2018 @ 9:36am 
Originally posted by 那就不原谅她了:
just set a variable(just like "pause") to tell whether looping or not
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.
Robablo Jan 4, 2018 @ 9:41am 
Originally posted by MrDave:
I think anyone else would have just asked how to do it rather than going off on a massive rant at YoyoGames. It really isn’t hard to do and you just show everyone who the inept programmer is. No one wants to help someone with a comment like this .
This was more of a vent then anything else. And just because I don't know GM quite yet doesn't make me "inept". I've looked up how to do it, and have recieved answers of how to do it, and none of them are what I need. I just need a line of code that stops the script from continuing for a number of frames. There seems to be no way of doing that without setting a variable to constantly tick every fram via a step event, and then setting that to 0, followed by running an if-then statement that asks what that variable is at. Way too inconvenient and inefficient for pausing a script.
OctalSmile Jan 9, 2018 @ 7:55pm 
Originally posted by thepicausno:
Originally posted by 那就不原谅她了:
just set a variable(just like "pause") to tell whether looping or not
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.
I'm not sure if this is exactly what he means, but I think he means that you can insert the code you want to pause right after the line of the if statement. Insert any code you want to carry out while pausing the game after the else statement.
Robablo Jan 10, 2018 @ 3:03pm 
Originally posted by OctalSmile:
Originally posted by thepicausno:

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.
I'm not sure if this is exactly what he means, but I think he means that you can insert the code you want to pause right after the line of the if statement. Insert any code you want to carry out while pausing the game after the else statement.

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?
Thew Jan 13, 2018 @ 6:00pm 
Originally posted by thepicausno:
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?
A pause like this could work in any and all events. Make a global variable for pause and wrap any code you want in a conditional that checks if pause is set to True. As long as you use the same variable, it will work across all events and objects that check that value.

/// Any Event if (!global.pause) { // Code in here will not execute if global.pause is True }
Robablo Jan 13, 2018 @ 6:57pm 
Originally posted by Thew:
A pause like this could work in any and all events. Make a global variable for pause and wrap any code you want in a conditional that checks if pause is set to True. As long as you use the same variable, it will work across all events and objects that check that value.
Step events are the only events that occur every frame. If I wanted something like this to happen, say, when a key was pressed once, I'd have to put it in a step event, since if I didn't, the action would only occur on the frame the button is pressed. And again,you can only have one step event. So if you already have alot of code in your step event, this only overcomplicates things even more.
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.
Thew Jan 16, 2018 @ 1:45pm 
Originally posted by thepicausno:
Step events are the only events that occur every frame. If I wanted something like this to happen, say, when a key was pressed once, I'd have to put it in a step event, since if I didn't, the action would only occur on the frame the button is pressed. And again,you can only have one step event. So if you already have alot of code in your step event, this only overcomplicates things even more.
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.
I'm having a little trouble figuring out what the specific problem is here. Why does it matter that you can only have one step event? (you do also have begin and end steps, if you need them though)

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.

// initialize the variable before you need to access it global.pause = false; if (keyboard_check_pressed(vk_space)) { // this will toggle the pause on and off when pressing 'space' global.pause = !global.pause; } if (!global.pause) { // this code will not execute if global.pause is True }
papacatOri Feb 15, 2018 @ 8:43am 
I'm far from a GM2 expert, but I think your problem lies in not understanding the structure of the game engine. Gamemaker isn't a programming language. It's a software package that is designed to be a shortcut to programming for specific types of applications. Like any other genre of software (such as 3D modeling or audio composing) different packages are going to have different controls and features. Even when those features are named similarly, they generally will not be quite the same between applications (like comparing Blender, Maya, and Carrara). Is it possable you are used to another application and are just unfamilliar with the new environment?

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
JT Feb 21, 2018 @ 9:09pm 
if ((numFramesPassed % numFramesToWait) == 0) { // call script }

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...

if (numFramesPassed == numFramesToWait) { numFramesPassed = 0; // call script }

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
< >
Showing 1-11 of 11 comments
Per page: 1530 50

Date Posted: Jan 2, 2018 @ 2:24pm
Posts: 11