The Dink Network

help with object moving script

September 10th 2006, 11:47 AM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
I am making a script to move to a destination by pushing, but there are bugs, as usual Someone please try to help me. There are two problems I'm having, but I can't seem to find a flaw in my script.

1) When you push the object from its original position, Dink says that he can't push it from that angle. After he says that, the rock warps off screen and Dink unfreezes. The hardness is still in the same place. This causes me to suspect it's not going to the moving procedure, but I cannot see why.

2) When pushing the rock back, he says his rock moving thing which informs me that he is going to the proper procedure, but the rock stays and Dink says frozen. What gives!?

Here is the script:
Note: I'm also going to make a variable for the proper directions so everything can be toggled in the main procedure.

//Object moving Script
void main( void )
{
int &my_dir;
int &x_cor;

int &seq;
int &frame;
&frame = sp_frame(&current_sprite, -1);
&seq = sp_seq(&current_sprite, -1);

int &start_cor;
int &end_cor;
&start_cor = 220;
&end_cor = 300;
}

void push(void)
{
&my_dir = sp_dir(1, -1);
&x_cor = sp_x(&current_sprite, -1);

freeze(1);

//the thing is in original position
if (&x_cor == &start_cor)
{
if (&my_dir == 6)
{
move_away();
}
}

//the thing has already been moved
if (&x_cor == &end_cor)
{
if (&my_dir == 4)
{
move_back();
}
}

say("I can't move it from this angle", 1);
unfreeze(1);
}

void move_away( void )
{
say("its moving", 1);
move_stop(&current_sprite, 6, &end_cor, 1);
draw_hard_map();

int &hold = sp_editor_num(&current_sprite);
if (&hold != 0)
{
editor_type(&hold, 3);
editor_seq(&hold, &seq);
editor_frame(&hold, &frame);
}
sp_x(&current_sprite, &end_cor);
unfreeze(1);
}

void move_back( void )
{
say("moving back", 1);
move_stop(&current_sprite, 4, &start_cor, 1);
draw_hard_map();

int &hold = sp_editor_num(&current_sprite);
if (&hold != 0)
{
editor_type(&hold, 3);
editor_seq(&hold, &seq);
editor_frame(&hold, &frame);
}
sp_x(&current_sprite, &start_cor);
unfreeze(1);
}
September 10th 2006, 12:16 PM
knightg.gif
cypry
Peasant He/Him Romania
Chop your own wood, and it will warm you twice. 
Well, after you call one procedure, it is executed and the initial procedure is continued. Try to use a return after each procedure call, like this:

if (&x_cor == &start_cor)
{
if (&my_dir == 6)
{
move_away();
return;
}
}
September 10th 2006, 12:58 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
I tried it. Now he says the "it's moving" part with both, but the other problems still ocur.
September 10th 2006, 01:36 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
You must set the sp_speed or else it won't move. With move_stop, this means the script freezes, since it waits until the object is at the destination, which'll never happen.
September 10th 2006, 03:10 PM
anon.gif
rabidwolf9
Ghost They/Them
 
That fixes things I feel dumb. The moving back still warps it, and they both move the rock to the 0 x coordinate. Maybe it won't use a variable?