Touching!
I have a question about the void touch (void) procedure.
Is it possible to trigger something when a sprite other than Dink touches a certain scripted object? For example, when Lyna touches a scripted wall, Dink says something.
Is this possible or anything that works like this?
Is it possible to trigger something when a sprite other than Dink touches a certain scripted object? For example, when Lyna touches a scripted wall, Dink says something.
Is this possible or anything that works like this?
You would have to use a loop to check if the certain sprite is in a specific range of coordinates using inside_box.
Eh, nvm this post, I seem to be on some kind of crack
loop:
wait(100);
int &x = sp_x(&sprite, -1);
int &y = sp_y(&sprite, -1);
int &box = inside_box(&x, &y, left, top, right, bottom);
//left, right etc set as touch area
if (&box)
{
//do stuff
}
goto loop;
Or if it's a straight area (like a wall) you could just use sp_x/y() instead of inside_box()...
loop:
wait(100);
&x = sp_x(&sprite, -1);
if (&x > ??)
{
//do stuff
}
goto loop;
...Heh, posted at the same time as Rabid.
wait(100);
int &x = sp_x(&sprite, -1);
int &y = sp_y(&sprite, -1);
int &box = inside_box(&x, &y, left, top, right, bottom);
//left, right etc set as touch area
if (&box)
{
//do stuff
}
goto loop;
Or if it's a straight area (like a wall) you could just use sp_x/y() instead of inside_box()...
loop:
wait(100);
&x = sp_x(&sprite, -1);
if (&x > ??)
{
//do stuff
}
goto loop;
...Heh, posted at the same time as Rabid.
better to set wall brain to 11 (missile) & use damage() function for touch code
Thanks, but I still don't quite get it... Let's say you have 2 scripts, one for a rock, with a "box" around it.
Would that script look like your script, so like this?
void main (void)
{
loop:
wait(100);
int &x = sp_x(&sprite, -1);
int &y = sp_y(&sprite, -1);
int &box = inside_box(&x, &y, 380, 175, 515, 220);
//left, right etc set as touch area
if (&box)
{
say("hey", 1);
}
goto loop;
}
And the other script, for Lyna, when she enters the box, something happens. How would that script look like?
Would that script look like your script, so like this?
void main (void)
{
loop:
wait(100);
int &x = sp_x(&sprite, -1);
int &y = sp_y(&sprite, -1);
int &box = inside_box(&x, &y, 380, 175, 515, 220);
//left, right etc set as touch area
if (&box)
{
say("hey", 1);
}
goto loop;
}
And the other script, for Lyna, when she enters the box, something happens. How would that script look like?
You can use the same script for both actions, you just have to know Lyna's sprite number. You can either:
Do a search for Lyna's sprite
Spawn Lyna's script directly
Save Lyna's sprite number into a global in the main procedure of Lyna's script, then read it from the box script
Save Lyna's sprite number into one of Dink's attributes and then read it back in the box script
Basically:
//Lyna's script
void main( void )
{
sp_gold(1, ¤t_sprite);
}
and before the loop in the other script:
//short wait to allow lyna's script to work
wait(1);
int &girl = sp_gold(1, -1);
Then just use another smaller loop to check both Dink and the girl, by reseting &sprite
Do a search for Lyna's sprite
Spawn Lyna's script directly
Save Lyna's sprite number into a global in the main procedure of Lyna's script, then read it from the box script
Save Lyna's sprite number into one of Dink's attributes and then read it back in the box script
Basically:
//Lyna's script
void main( void )
{
sp_gold(1, ¤t_sprite);
}
and before the loop in the other script:
//short wait to allow lyna's script to work
wait(1);
int &girl = sp_gold(1, -1);
Then just use another smaller loop to check both Dink and the girl, by reseting &sprite











