Prowler Productions
  Dink Smallwood Forum
  Beginner problems

Post New Topic  
profile | register | faq

Author Topic:   Beginner problems
DigiBO posted 02-24- 01:16 PM CT (US)   Click Here to See the Profile for DigiBO   Click Here to Email DigiBO  
I am trying to make a place where when you step it takes you 1 life and gives you 10 exp.What I did was attaching a script to an invisible sprite.It just doesn't work.What I did wrong?Here is the script:
void main( void )
{
sp_touch_damage(¤t_sprite, -1);
}

void touch( void )
{
wait(1000);
loop:
&life -= 1;
&exp += 10;
wait(500);
goto loop ;
}

Any ideas?

Beuc posted 02-24- 02:43 PM CT (US)     Click Here to See the Profile for Beuc  Click Here to Email Beuc     

Just add sp_nohit(&current_sprite, 1); in your main.

But beware! There's two other errors!



When you touch the sprite, the touch is called and called and called, because Dink continues touching it... And so the touch() procedure is called, begin the wait(1000), but is called again because Dink is still touching the sprite, then begin to wait(1000), then is called again...



This ends when Dink don't touch the sprite anymore, but the script continues! So after wait(1000), life is increased, exp is increased, then wait(500), it's OK; but then there's a loop, so the script goes to loop:, then life is decreased, exp increased, and so on, and Dink dies...



You may place some sprite with a space between them, then for each of them attach:



void main( void )
{
   sp_touch_damage(&current_sprite, -1);
   sp_nohit(&current_sprite, 1);
   int &touched = 0;
}



void touch( void )
{
   if (touched==0)
   {
      &life -= 1;
      &exp += 10;
   }
   touched = 1;
}


Then it should be OK... but test it anyway, I'm really not sure ;)

redink1 posted 02-24- 05:05 PM CT (US)     Click Here to See the Profile for redink1  Click Here to Email redink1     
Just another thing to add... what are you doing to make the sprite invisible? Are you changing its type to 2? Sprites with type 2 cannot have scripts attached to them. The best way to make an invisibile sprite that has a script is to set its size to 1.
DigiBO posted 02-25- 02:24 AM CT (US)     Click Here to See the Profile for DigiBO  Click Here to Email DigiBO     
Well maybe I just should remove the loop and put sp_nohit?

But how will your version work if it works only when &touched is 0 and at the end of it you make it 1.Won't it stop working?


I didn't know that sivisible sprites can't have a script attached!
Will it works good if I make it small?

Beuc posted 02-25- 08:21 AM CT (US)     Click Here to See the Profile for Beuc  Click Here to Email Beuc     
I just did that to avoid Dink been beaten 20 times per second...
I don't know how to do exactly, try to see... :)
DigiBO posted 02-25- 10:45 AM CT (US)     Click Here to See the Profile for DigiBO  Click Here to Email DigiBO     
Damn!This is thing is driving me crazy!
I made the thing type 1(background).Shrunk it to 1 and added the following script:

void main( void )
{
sp_touch_damage(¤t_sprite, -1);
sp_nohit(¤t_sprite, 1);
}

void touch( void )
{
wait(500);
&life -= 1;
&exp += 10;
}

But it just doesn't work!It doesn't give me exp even once!Nothing works.I double and even triple checked if I have attached script.Everything seems right!!!!!

Beuc posted 02-26- 11:15 AM CT (US)     Click Here to See the Profile for Beuc  Click Here to Email Beuc     
Well, in fact, when you touch the sprite, Dink call your touch() script, it do a wait(500), but as Dink is still touching the sprite, then Dink calls another time the touch() procedure, and forget the previous call, and so on...

Stop touching the sprite, and then Dink will gain 10 exp after 1/2 sec I think.

May be OK like this eventually :|

DigiBO posted 02-28- 09:49 AM CT (US)     Click Here to See the Profile for DigiBO  Click Here to Email DigiBO     
Finally got it to work(almost give up Dmod making!)
The first mistake was that I didn't change the sprite to type 1.
Figured out the script also:

void main( void )
{
sp_touch_damage(¤t_sprite, -1);
sp_nohit(¤t_sprite, 1);
int &altar
&altar = 1;
}

void touch( void )
{
if (&altar == 1)
{
&altar = 0;
sp_touch_damage(¤t_sprite, 0);
&life -= 1;
&exp += 10;
wait(500);
&altar = 1;
sp_touch_damage(¤t_sprite, -1);
}
}

A bit fast,but exactly what I needed!

Beuc posted 03-01- 06:29 AM CT (US)     Click Here to See the Profile for Beuc  Click Here to Email Beuc     
Excellent!

I didn't think of it, using sp_touchdamage() and so.
Great :)


Ask again if you need

Post New Topic  Post Reply
Hop to:


Contact Us | Prowler Productions

Powered by: Ultimate Bulletin Board, Freeware Version 5.10a
Purchase our Licensed Version- which adds many more features!
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.