The Dink Network

Sprite numbers

December 20th 2004, 08:53 PM
goblins.gif
igloo15
Peasant He/Him
 
void main (void)
{
int &per1;
int &per2;
external("duck1", gvoice);
&per1 = &voice;
external("duck2", gvoice);
&per2 = &voice;
wait(500);
say("hello dink &per1", &per1);
say("don't listen to him dink", &per2);
}
what could be wrong with this script. &voice is a global variable and the duck1 script looks like the following

void gvoice (void)
{
&voice = sp(25);
}

25 being the sprite's editor number that the script duck1 is attached too.

the same exact thing for duck2 only it is sp(26);

December 20th 2004, 11:04 PM
goblinm.gif
I recall the command as external("duck1","gvoice"), but feel free to slap me if that's wrong
December 21st 2004, 12:32 AM
pq_frog.gif
Ric
Peasant They/Them Canada
 
Ya, external("","");
quotes on both.
Nice way to use one global to chage multiple locals.
Try//duck1
void gvoice (void)
{
&voice = &current_sprite;
}
Seems to me the sprite # is what you can look for. You could even use the same 'duck1 script for multiple sprites since that first script changes locals sequensialy.
December 21st 2004, 08:17 AM
pq_frog.gif
Ric
Peasant They/Them Canada
 
Oops, no they will need separate scripts. In fact, doing it this way may not work with external. If I remember right external makes that procedure act like it is part of the first script, so &voice would get set to the first sprite.
I'd just use a global for each, they could be reused elsewhere as long as that's the only thing they do on that screen.
December 21st 2004, 10:38 AM
goblins.gif
igloo15
Peasant He/Him
 
I thought external ran the proc in the script and then killed it after it was run. I knew i would need a seperate script for each but it would be better then using globals.
December 21st 2004, 11:02 AM
goblins.gif
igloo15
Peasant He/Him
 
well I was correct this script works so you only have to define one global variable and both sprites were now able to be totally controlled.
void main (void)
{

int &per1;
int &per2;
wait(500);
external("duck1", "gvoice");
&per1 = &voice;
wait(500);
say("hello dink &per1", &per1);
wait(500);
external("duck2", "gvoice");
&per2 = &voice;
wait(500);

say_stop("don't listen to him dink", &per2);

wait(500);
say_stop("hello again", &per1);
wait(500);
say_stop("you stupid", &per2);

}

I did some more testing to see what the least amount of work had to be done to make it work.

int &per1;
int &per2;
int &per3;
wait(100);
external("duck1", "gvoice");
&per1 = &voice;
wait(100);
external("duck2", "gvoice");
&per2 = &voice;
wait(100);
external("duck3", "gvoice");
&per3 = &voice;

this will work for as many sprites as you want. I think this can be used for other things two so if you just want to use one variable to create a number of different variables in a script you could use this method.