The Dink Network

how do i make the scrip to show just one time

October 26th 2009, 07:39 PM
fairy.gif
GlennGlenn
Peasant He/Him Norway
GlennGlenn doesn't want a custom title. 
how do i make the scrip to show just one time
October 26th 2009, 07:49 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
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
October 26th 2009, 09:14 PM
slayer.gif
MadStalker
Peasant He/Him Finland
tag line 
Glenn, you are a baaaaad baaaaad boy!
October 26th 2009, 09:40 PM
knights.gif
DinkKiller
Peasant He/Him United States
The world could always use more heroes 
lol
October 27th 2009, 12:46 PM
duck.gif
wesley
Peasant He/Him United States
 
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(&current_sprite, -1);

if(&state == 0)
{
//do stuff
...

//set the "state" to something other than 0
editor_seq(&current_sprite, 1);
}
}