The Dink Network

sp_target() bug

September 21st 2005, 05:32 PM
spike.gif
Using sprite numbers for targetting:

sp_target(&current_sprite, ##);
makes it target sp(##); -1

For example:

sp_target(&current_sprite, 13);
actually does
sp_target(&current_sprite, 12);
September 22nd 2005, 01:53 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Strange, I tested this and it doesn't seem to do this with me...

I tested it using this script:

void main(void)
{
int &testspr = create_sprite(544,50,0,421,2);
sp_target(&current_sprite,&testspr);
int &difver = sp_target(&current_sprite,-1);
say("&testspr &difver",1);
}

In my case Dink said 7 7. And when I looked at the bonca to wich this script was attached, it tried to attack the sprite I created.

Maybe it has to do with your version of Dink? I have version 1.07 installed.
September 22nd 2005, 02:01 PM
spike.gif
Even

int &target = sp(13);
sp_target(&current_sprite, &target);

works right. But try targetting a sprite created by the editor directly, ie.

sp_target(&current_sprite, 13);
September 22nd 2005, 02:17 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
13 is the sprite number as found in the editor, right? This is the sp_editor_num(##), or the "editor number". The sprite with "editor number" 1 will be the first sprite placed on the screen in the editor, not Dink. All script commands need "sprite numbers". Conversion is done with sp(##). Look at

int &crap = sp_editor_num(&current_sprite);
int &trash = sp(&crap);
if (&current_sprite == &trash)
{
say("Always says this if sprite is placed in the editor",&current_sprite);
}

and:

int &crap = sp(13);
int &trash = sp_editor_num(&crap);
if (&trash == 13)
{
say("Always says this if sprite is placed in the editor",&current_sprite);
}