Help with script please
I need help with a script.After Dink pays this guy, the guy
is supposed to walk off the screen but it just freezes up.
After he walks off, it should also force vision to '0'.
And then DInk should unfreeze.(I have a vision sctipt on the base
of the screen as well)
Here is my script...
void main( void )
{
void hit( void )
{
say("`3Oww, bug off jerk!", ¤t_sprite);
}
void talk( void )
{
freeze(1);
choice_start();
set_y 240
set_title_color 9
title_start();
"A tall man with brown hair and a sly grin stands here"
title_end();
"Pay the toll"
"Argue"
"Leave"
choice_end();
if (&result == 1)
{
if (&gold < 100)
{
wait(500);
say_stop("`3You don't have enough gold!", ¤t_sprite);
unfreeze(1);
return;
}
if (&gold > 99)
{
wait(500);
say_stop("`3Thanks. See ya.", ¤t_sprite);
&gold -= 100;
move_stop(¤t_sprite, 4, -50, 1);
&story = 4;
unfreeze(1);
force_vision(0);
kill_this_task();
return;
}
}
if (&result == 2)
{
wait(500);
say_stop("How come I have to pay?",1);
wait(500);
say_stop("`3Just doing my job, kid.", ¤t_sprite);
wait(500);
say_stop("Well, 100 gold is a little high!", 1);
wait(500);
say_stop("`3Then leave!", ¤t_sprite);
wait(500);
say_stop("Jerk!", 1);
unfreeze(1);
return;
}
}
}
is supposed to walk off the screen but it just freezes up.
After he walks off, it should also force vision to '0'.
And then DInk should unfreeze.(I have a vision sctipt on the base
of the screen as well)
Here is my script...
void main( void )
{
void hit( void )
{
say("`3Oww, bug off jerk!", ¤t_sprite);
}
void talk( void )
{
freeze(1);
choice_start();
set_y 240
set_title_color 9
title_start();
"A tall man with brown hair and a sly grin stands here"
title_end();
"Pay the toll"
"Argue"
"Leave"
choice_end();
if (&result == 1)
{
if (&gold < 100)
{
wait(500);
say_stop("`3You don't have enough gold!", ¤t_sprite);
unfreeze(1);
return;
}
if (&gold > 99)
{
wait(500);
say_stop("`3Thanks. See ya.", ¤t_sprite);
&gold -= 100;
move_stop(¤t_sprite, 4, -50, 1);
&story = 4;
unfreeze(1);
force_vision(0);
kill_this_task();
return;
}
}
if (&result == 2)
{
wait(500);
say_stop("How come I have to pay?",1);
wait(500);
say_stop("`3Just doing my job, kid.", ¤t_sprite);
wait(500);
say_stop("Well, 100 gold is a little high!", 1);
wait(500);
say_stop("`3Then leave!", ¤t_sprite);
wait(500);
say_stop("Jerk!", 1);
unfreeze(1);
return;
}
}
}
1) force_vision does not do anything.
2) Don't put the 'talk' and 'hit' functions inside the 'main' function. That's just weird.
Try replacing force_vision with draw_screen(); Not sure why it freezes, though.
2) Don't put the 'talk' and 'hit' functions inside the 'main' function. That's just weird.
Try replacing force_vision with draw_screen(); Not sure why it freezes, though.
Don't put the 'talk' and 'hit' functions inside the 'main' function.
But I always do that.
Are you saying I should close the main before I do the talk
and hit functions or should I leave the whole 'main' thing off
the script?
But I always do that.
Are you saying I should close the main before I do the talk
and hit functions or should I leave the whole 'main' thing off
the script?
main() is just another way of saying "Do this when you see me", same as talk() means "Do this when you talk to me" and hit() means "Do this when you hit me".
So yes, it should be separate. If it's empty, you can leave it out.
So yes, it should be separate. If it's empty, you can leave it out.
Okay, so would this work...
if (&gold > 99)
{ wait(500);
say_stop("`3Thanks. See ya.", ¤t_sprite);
&gold -= 100;
move_stop(¤t_sprite, 4, -50, 1);
&story = 4;
draw_screen();
unfreeze(1);
return; }
Cuz that looks kinda weird to me.Then again, most scripts do.
or what about like this...
if (&gold > 99)
{ wait(500);
say_stop("`3Thanks. See ya.", ¤t_sprite);
&gold -= 100;
move_stop(¤t_sprite, 4, -50, 1);
&story = 4;
fade_down();
fill_screen(0);
//take Player to story 4
&player_map = 198;
draw_background();
load_screen();
draw_screen();
sp_x(1, 380);
sp_y(1, 310);
&update_status = 1;
draw_status();
unfreeze(1);
sp_nodraw(1, 0);
wait(200);
fade_up();
kill_this_task();
return;
}
if (&gold > 99)
{ wait(500);
say_stop("`3Thanks. See ya.", ¤t_sprite);
&gold -= 100;
move_stop(¤t_sprite, 4, -50, 1);
&story = 4;
draw_screen();
unfreeze(1);
return; }
Cuz that looks kinda weird to me.Then again, most scripts do.
or what about like this...
if (&gold > 99)
{ wait(500);
say_stop("`3Thanks. See ya.", ¤t_sprite);
&gold -= 100;
move_stop(¤t_sprite, 4, -50, 1);
&story = 4;
fade_down();
fill_screen(0);
//take Player to story 4
&player_map = 198;
draw_background();
load_screen();
draw_screen();
sp_x(1, 380);
sp_y(1, 310);
&update_status = 1;
draw_status();
unfreeze(1);
sp_nodraw(1, 0);
wait(200);
fade_up();
kill_this_task();
return;
}
The script is aborted when using draw_screen(); so any code after that will be ignored.
Also, what is the sp_speed of ¤t_sprite? If it's 0, it can't move, which might explain its frozyness.
EDIT: That was for the older version. In the "what about this" thing, you'll need to do script_attach(1000); somewhere before draw_screen(), as draw_screen() aborts the script.
Braces ( { and } )should have their own line.
Also, what is the sp_speed of ¤t_sprite? If it's 0, it can't move, which might explain its frozyness.
EDIT: That was for the older version. In the "what about this" thing, you'll need to do script_attach(1000); somewhere before draw_screen(), as draw_screen() aborts the script.
Braces ( { and } )should have their own line.
I didn't give the current sprite anything.*tsk tsk*
Men! Always wanting more.
So the script is aborted if I use draw screen, what exactly
happens then? I mean, the script stops but will it reload the
screen? Will my & story update, will my vision change happen?
I think I'm just gonna kill the guy off.He's too much trouble.
Men! Always wanting more.
So the script is aborted if I use draw screen, what exactly
happens then? I mean, the script stops but will it reload the
screen? Will my & story update, will my vision change happen?
I think I'm just gonna kill the guy off.He's too much trouble.
Don't kill him, please
From dinkc.chm, entry: draw_screen:
draw_screen draws the last screen loaded, either explicitly loaded by load_screen or implicitly loaded when Dink walked onto the current screen. It also runs the main() procedures of any scripts attached to the screen or its sprites.
This command is generally used after a load_screen or to redraw the current screen after it has been messed up by certain commands such as fill_screen or copy_bmp_to_screen. It can also be used to change visions, if the base script is setup accordingly (i.e. &vision can only be changed in the base script, not in the script calling draw_screen).
If the script executing draw_screen is attached to a screen or a sprite, that script is abandoned when the draw_screen command is started. Use script_attach(1000) to prevent this from happening. Alternatively, just make sure that main() in the new screen's script does any cleanup after the warp, such as a fade_up or sp_nodraw(1,0).
Everything after draw_screen will never happen, unless you put script_attach(1000) somewhere (before it). Everything before it just works. This means that &story will update. The vision change only happens if you have a script attached to the screen that does so. You wanted it to have vision 0, which is default, so unless you do some strange stuff in that script, it works.
From dinkc.chm, entry: draw_screen:
draw_screen draws the last screen loaded, either explicitly loaded by load_screen or implicitly loaded when Dink walked onto the current screen. It also runs the main() procedures of any scripts attached to the screen or its sprites.
This command is generally used after a load_screen or to redraw the current screen after it has been messed up by certain commands such as fill_screen or copy_bmp_to_screen. It can also be used to change visions, if the base script is setup accordingly (i.e. &vision can only be changed in the base script, not in the script calling draw_screen).
If the script executing draw_screen is attached to a screen or a sprite, that script is abandoned when the draw_screen command is started. Use script_attach(1000) to prevent this from happening. Alternatively, just make sure that main() in the new screen's script does any cleanup after the warp, such as a fade_up or sp_nodraw(1,0).
Everything after draw_screen will never happen, unless you put script_attach(1000) somewhere (before it). Everything before it just works. This means that &story will update. The vision change only happens if you have a script attached to the screen that does so. You wanted it to have vision 0, which is default, so unless you do some strange stuff in that script, it works.
I got it to work!!
I went with this:
void main( void )
{
int &dumb = create_sprite(360, 300, 0, 64, 1);
sp_hard(&dumb, 0);
draw_hard_sprite(&dumb);
sp_disabled(&dumb, 1);
sp_base_walk(¤t_sprite, 370);
sp_speed(¤t_sprite, 3);
sp_timing(¤t_sprite, 0);
}
void hit( void )
{
say("`3Wimp!", ¤t_sprite);
}
void talk( void )
{
freeze(1);
choice_start();
set_y 240
set_title_color 9
title_start();
"A tall man with brown hair and a sly grin stands here"
title_end();
"Pay the toll"
"Argue"
"Leave"
choice_end();
if (&result == 1)
{
if (&gold < 100)
{
wait(500);
say_stop("`3You don't have enough gold!", ¤t_sprite);
unfreeze(1);
return;
}
if (&gold > 99)
{
wait(500);
say_stop("`3Thanks. See ya.", ¤t_sprite);
&gold -= 100;
move_stop(¤t_sprite, 4, -50, 1);
&story = 4;
force_vision(0);
unfreeze(1);
return;
}
}
if (&result == 2)
{
wait(500);
say_stop("How come I have to pay?",1);
wait(500);
say_stop("`3Just doing my job, kid.", ¤t_sprite);
wait(500);
say_stop("Well, 100 gold is a little high!", 1);
wait(500);
say_stop("`3Then leave!", ¤t_sprite);
wait(500);
say_stop("Jerk!", 1);
}
unfreeze(1);
}
Plus I had a vision script on the base.SO it's all good.
In fact, my game is now playable right through.Just want
to add some more 'new graphics' and then I guess I'll
submit it.YAY! I probably won't win but I'm glad I finally
worked out the glitches.Heh.
Thanks redink1 and magicman!
I went with this:
void main( void )
{
int &dumb = create_sprite(360, 300, 0, 64, 1);
sp_hard(&dumb, 0);
draw_hard_sprite(&dumb);
sp_disabled(&dumb, 1);
sp_base_walk(¤t_sprite, 370);
sp_speed(¤t_sprite, 3);
sp_timing(¤t_sprite, 0);
}
void hit( void )
{
say("`3Wimp!", ¤t_sprite);
}
void talk( void )
{
freeze(1);
choice_start();
set_y 240
set_title_color 9
title_start();
"A tall man with brown hair and a sly grin stands here"
title_end();
"Pay the toll"
"Argue"
"Leave"
choice_end();
if (&result == 1)
{
if (&gold < 100)
{
wait(500);
say_stop("`3You don't have enough gold!", ¤t_sprite);
unfreeze(1);
return;
}
if (&gold > 99)
{
wait(500);
say_stop("`3Thanks. See ya.", ¤t_sprite);
&gold -= 100;
move_stop(¤t_sprite, 4, -50, 1);
&story = 4;
force_vision(0);
unfreeze(1);
return;
}
}
if (&result == 2)
{
wait(500);
say_stop("How come I have to pay?",1);
wait(500);
say_stop("`3Just doing my job, kid.", ¤t_sprite);
wait(500);
say_stop("Well, 100 gold is a little high!", 1);
wait(500);
say_stop("`3Then leave!", ¤t_sprite);
wait(500);
say_stop("Jerk!", 1);
}
unfreeze(1);
}
Plus I had a vision script on the base.SO it's all good.
In fact, my game is now playable right through.Just want
to add some more 'new graphics' and then I guess I'll
submit it.YAY! I probably won't win but I'm glad I finally
worked out the glitches.Heh.
Thanks redink1 and magicman!










