I Need help with a script...
Does anyone know how to make it so when I run a script it only runs 1 time when go to that screen??
Im a novice Author. I know alot of the basics and stuff but, Not all of them.
Im a novice Author. I know alot of the basics and stuff but, Not all of them.
attach it to some object on screen and then put it in the main method. This will cause it to run once and only when you first enter the screen. Now if you want to only allow it to run once when you enter screen and then leave and comeback and not run again you will have to play with some variables to make sure it doesn't run again.
Make a global variable. (they're commonly in main.c)
For example
make_global_int("&mammothleg", 0);
Then do this for what you want to only run once:
if (&mammothleg == 0)
{
&mammothleg = 1;
//stuff that happens here
}
Next time the script is entered the stuff in the brackets won't run because if (&mammothleg == 0) is false.
For example
make_global_int("&mammothleg", 0);
Then do this for what you want to only run once:
if (&mammothleg == 0)
{
&mammothleg = 1;
//stuff that happens here
}
Next time the script is entered the stuff in the brackets won't run because if (&mammothleg == 0) is false.
Don't u need to have &mammothleg = 1; on the bottom or doesn't that matter?
Or even better, attach it to some object on the screen, put it in the main proc, right after sp_nodraw(¤t_sprite, 1); This makes it invisible. Type 2 in the editor won't work. For some strange reasons Type 2 sprites won't run scripts...
Then place the following code after it has done its job:
int &hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
{
editor_type(&hold, 3);
}
sp_brain(¤t_sprite, 5);
sp_notouch(¤t_sprite, 1);
sp_nohit(¤t_sprite, 1);
sp_hard(¤t_sprite, 1);
draw_hard_sprite(¤t_sprite);
sp_active(¤t_sprite, 0);
kill_this_task();
It's copied from some barrel script or something, but slightly modified. It makes the sprite disappear from the map forever, so it executes the code when you enter the screen and destroys itself, so it can never execute again.
Then place the following code after it has done its job:
int &hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
{
editor_type(&hold, 3);
}
sp_brain(¤t_sprite, 5);
sp_notouch(¤t_sprite, 1);
sp_nohit(¤t_sprite, 1);
sp_hard(¤t_sprite, 1);
draw_hard_sprite(¤t_sprite);
sp_active(¤t_sprite, 0);
kill_this_task();
It's copied from some barrel script or something, but slightly modified. It makes the sprite disappear from the map forever, so it executes the code when you enter the screen and destroys itself, so it can never execute again.
Well, the only line needed is
editor_type(¤t_sprite, 1);
editor_frame(); is also good for random npcs who introduce themselves the first time met or whatever. There's, what, 10 frames and 4 sequences normal walking sprites have so they can actually hold 40 different values...
Still, globals are the simplest and most powerful way for handling permanent events.
editor_type(¤t_sprite, 1);
editor_frame(); is also good for random npcs who introduce themselves the first time met or whatever. There's, what, 10 frames and 4 sequences normal walking sprites have so they can actually hold 40 different values...
Still, globals are the simplest and most powerful way for handling permanent events.
editor_frame(); is also good for random npcs who introduce themselves the first time met or whatever. There's, what, 10 frames and 4 sequences normal walking sprites have so they can actually hold 40 different values...
I thought they could only hold 2 different values: 1 for frame and one for sequence?
Also, I would prefer to use the editor trick than to waste globals on such a small task.
I thought they could only hold 2 different values: 1 for frame and one for sequence?
Also, I would prefer to use the editor trick than to waste globals on such a small task.
Sabre is right on this. It remembers editor_seq() and editor_frame().
editor_type(¤t_sprite,#) doesn't work every time. You really need sp_editor_num(¤t_sprite) for that.
editor_type(¤t_sprite,#) doesn't work every time. You really need sp_editor_num(¤t_sprite) for that.