The Dink Network

Pick the thing up!

November 15th 2002, 07:33 PM
pq_skard.gif
Hey everyone. Got a question. I write a script that creates a sprite when Dink enters a screen. That part work fine. The sprite I want is where I want it. However, I want Dink to pick the thing up. I modified a potion script using: void touch(void), but Dink just walks over the sprite. I didn't modify the script much as I wanted to go bit by bit to make error testing easier. Here is a snippet. What's wrong?

void main(void)

{

int &exlax = create_sprite(145, 171, 0, 163, 3);

}

void touch( void )

{

say("Cool. Got the exlax.",1);

Playsound(10,22050,0,0,0);

//shrink to this percent then die

int &hold = sp_editor_num(&current_sprite);

if (&hold != 0)

{

//this was placed by the editor, lets make it not come back

editor_type(&hold, 1);

//kill food forever

}

}

Many TIA!
November 15th 2002, 11:11 PM
wizardg.gif
Paul
Peasant He/Him United States
 
: Hey everyone.  Got a question.  I write a script that creates a sprite when Dink enters a screen.  That part work fine.  The sprite I want is where I want it.  However, I want Dink to pick the thing up.  I modified a potion script using: void touch(void), but Dink just walks over the sprite.  I didn't modify the script much as I wanted to go bit by bit to make error testing easier.  Here is a snippet.  What's wrong?

: void main(void)

: {

: int &exlax = create_sprite(145, 171, 0, 163, 3);

: }

: void touch( void )

: {

: say("Cool. Got the exlax.",1);

: Playsound(10,22050,0,0,0);

: //shrink to this percent then die

:  int &hold = sp_editor_num(&current_sprite);

:  if (&hold != 0)

:    {

:     //this was placed by the editor, lets make it not come back

:     editor_type(&hold, 1);

:     //kill food forever

:    }

: }

: Many TIA!

Yoou have to set it's touch_damage to -1 or touch() won't run. Also be aware that editor_type doesn't apply to sprites created from a script. Instead you'll just have to make sure the script won't create it again if he's already taken it. And actually, now that I look at it, you don't have a command to kill it at all. You'll either want to set sp_active to 0 (vanish instantly) or sp_brain to 12, sp_brain_parm to some small number (shrink to nothing). If you use the last method, make sure to set touch_damage to 0 as well or Dink can "touch" it again while it's slowly shrinking and get more than one.