• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

If and Scripts

E

egor chernyshev

Guest
Hello, I am new to the Gamemaker studio 1 , so the question might seem to be quiet silly but how do you write ( if the script was executed) in GML.

for example I want code

if ( script was executed ) instance_create
 

Conbeef

Member
In the script have it returning 1 if successful and 0 if not
Example :

Script
///is_even
if argument0 mod 2 == 0{
return 1;
}else{
return 0;
}

Step event or whatever...
if is_even(random_number)
//Execute code
 
N

Noba

Guest
well err, here's a pretty weird way to do it but you could set a global variable somewhere, when the game is run for example
Code:
global.ifscriptisexecuted = 0; (or similar)
then in your script;
Code:
global.ifscriptisexecuted = 1;
then in the step event of your object checking if the script is executed;
Code:
if(global.ifscriptisexecuted = 1)
{
instance_create
}
Personally I don't make many scripts so I don't really know if this will work, but I'd imagine so.
 

Conbeef

Member
I should have used true and false to make it more clearer. In game maker
true = 1
false = 0

If I remember correctly
 
Top