how do i make the scrip to show just one time
how do i make the scrip to show just one time
glennglenn, I'm not sure at all why this is in this thread, but I will answer the question regardless.
I'm assuming you have a script attached to either a sprite or a room, and you want it to trigger the first time dink enters, but no other times. Correct me if I am wrong.
Now, to do this you'll need a global. In main.c you'll see a list of all the globals being initiated. Add your own with this command, replacing "whatever" with .. well.. whatever you wish..
make_global_int("&whatever", 0);
The number zero means it starts out set as 0, and the "&" is important, it marks it as a variable.
Now, simply have the script like this:
void main(void)
{
if (&whatever == 0)
{
//stuff
&whatever = 1;
}
}
Thus, when &whatever = 0, at the start of the dmod, it will run, and when it runs, it sets it to 1, therefore it will not run again.
Thanks, OkalyDDude
I'm assuming you have a script attached to either a sprite or a room, and you want it to trigger the first time dink enters, but no other times. Correct me if I am wrong.
Now, to do this you'll need a global. In main.c you'll see a list of all the globals being initiated. Add your own with this command, replacing "whatever" with .. well.. whatever you wish..
make_global_int("&whatever", 0);
The number zero means it starts out set as 0, and the "&" is important, it marks it as a variable.
Now, simply have the script like this:
void main(void)
{
if (&whatever == 0)
{
//stuff
&whatever = 1;
}
}
Thus, when &whatever = 0, at the start of the dmod, it will run, and when it runs, it sets it to 1, therefore it will not run again.
Thanks, OkalyDDude
I prefer to do the following. This saves you from using a global variable.
I've been away from scripting for a bit so excuse me if the syntax is a bit wrong.
void main(void)
//get the "state" of this sprite. It can be an invisible sprite. You
int &state = editor_seq(¤t_sprite, -1);
if(&state == 0)
{
//do stuff
...
//set the "state" to something other than 0
editor_seq(¤t_sprite, 1);
}
}
I've been away from scripting for a bit so excuse me if the syntax is a bit wrong.
void main(void)
//get the "state" of this sprite. It can be an invisible sprite. You
int &state = editor_seq(¤t_sprite, -1);
if(&state == 0)
{
//do stuff
...
//set the "state" to something other than 0
editor_seq(¤t_sprite, 1);
}
}