The Dink Network

I Need help with a script...

September 16th 2005, 02:31 AM
pillbug.gif
XXhex
Peasant He/Him
 
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.
September 16th 2005, 09:17 AM
goblins.gif
igloo15
Peasant He/Him
 
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.
September 16th 2005, 09:43 AM
spike.gif
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.
September 16th 2005, 10:25 AM
fairy.gif
Glennglenn
Peasant He/Him Norway
GlennGlenn doesn't want a custom title. 
Don't u need to have &mammothleg = 1; on the bottom or doesn't that matter?
September 16th 2005, 01:48 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Or even better, attach it to some object on the screen, put it in the main proc, right after sp_nodraw(&current_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(&current_sprite);
if (&hold != 0)
{
editor_type(&hold, 3);
}
sp_brain(&current_sprite, 5);
sp_notouch(&current_sprite, 1);
sp_nohit(&current_sprite, 1);
sp_hard(&current_sprite, 1);
draw_hard_sprite(&current_sprite);
sp_active(&current_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.
September 16th 2005, 02:12 PM
spike.gif
Well, the only line needed is
editor_type(&current_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.
September 16th 2005, 04:32 PM
custom_fish.png
SabreTrout
Noble He/Him United Kingdom
Tigertigertiger. 
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.
September 16th 2005, 04:39 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Sabre is right on this. It remembers editor_seq() and editor_frame().

editor_type(&current_sprite,#) doesn't work every time. You really need sp_editor_num(&current_sprite) for that.
September 16th 2005, 05:44 PM
anon.gif
XXhex
Ghost They/Them
 
Thanks for the help and I'll try that out.