i could use some help
im creating my first game and ineed to make a count down timer of some sort can anyone help
Here's a sample script for a timer. Pretty simple actually.
void main ()
{
script_attach(1000);
//number of seconds on the timer
int &count = 60;
int #
loop:
if (&count > 0)
{
if (&count == 1)
&num = say_xy("&count second remaining",0,0);
else
&num = say_xy("&count seconds remaining",0,0);
sp_kill(&num,1000);
wait(1000);
&count -= 1;
goto loop;
}
say_stop("Oh no, I'm out of time!",1);
kill_this_task();
}
void main ()
{
script_attach(1000);
//number of seconds on the timer
int &count = 60;
int #
loop:
if (&count > 0)
{
if (&count == 1)
&num = say_xy("&count second remaining",0,0);
else
&num = say_xy("&count seconds remaining",0,0);
sp_kill(&num,1000);
wait(1000);
&count -= 1;
goto loop;
}
say_stop("Oh no, I'm out of time!",1);
kill_this_task();
}
&num is the variable attached to the text so the text can be killed after exactly one second. Otherwise two texts with different remaining time might be displayed at the same time....
script_attach(1000); is to make sure that the script isn't attached to anything so it doesn't die after a screenchange.
script_attach(1000); is to make sure that the script isn't attached to anything so it doesn't die after a screenchange.
From memory, need { } even when there's only one line if that line is setting a variable. ie
if (&count == 1)
{
&num = say_xy("&count second remaining",0,0);
}
else
{
&num = say_xy("&count seconds remaining",0,0);
}
if (&count == 1)
{
&num = say_xy("&count second remaining",0,0);
}
else
{
&num = say_xy("&count seconds remaining",0,0);
}
Yes, you are right, Someone:
DinkC knows that if there are not any curly braces after an if statement that it will only apply to the next statement.
However, there is one critical error. This does not work for anything involving variables.
void talk(void)
{ int &temp = 0; // This will not work!! if (&life == &lifemax) &temp = 1;
}
To properly assign variables in if statements, you must use the curly braces.
void talk(void)
{ int &temp = 0; // This works fine. if (&life == &lifemax) { &temp = 1; }
}
DinkC knows that if there are not any curly braces after an if statement that it will only apply to the next statement.
However, there is one critical error. This does not work for anything involving variables.
void talk(void)
{ int &temp = 0; // This will not work!! if (&life == &lifemax) &temp = 1;
}
To properly assign variables in if statements, you must use the curly braces.
void talk(void)
{ int &temp = 0; // This works fine. if (&life == &lifemax) { &temp = 1; }
}
I completely forgot about that
It did work though. Go figure.

May 29th 2008, 09:44 AM

metatarasal


No, you're wrong.
Even the original game has this set of lines in most monsters:
int &hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
editor_type(&hold,<value
;
I don't use the curly brackets quite often and it hasn't failed me yet. I used it in multiple scripts in 'The scourger' and it seems to work well enough.
Rabid's script would work just fine...
Even the original game has this set of lines in most monsters:
int &hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
editor_type(&hold,<value

I don't use the curly brackets quite often and it hasn't failed me yet. I used it in multiple scripts in 'The scourger' and it seems to work well enough.
Rabid's script would work just fine...
Deanster: I've just uploaded a countdown timer script actually, so take a look at that when it's ready.
About the curly brackets, I think it's like Someone and DD95 say, that you can't set a variable that way. It works usually, but with a chance of screwing up.
If there's no variables involved you can often do it all on the same line, for example:
if (&cheese == 54) say("Cheese!", ¤t_sprite);
About the curly brackets, I think it's like Someone and DD95 say, that you can't set a variable that way. It works usually, but with a chance of screwing up.
If there's no variables involved you can often do it all on the same line, for example:
if (&cheese == 54) say("Cheese!", ¤t_sprite);
Yes, you are right, metatarasal.
DinkDude was quoting the DinkC reference, but the DinkC reference lies.
DinkC reference example:
void talk(void)
{
int &temp = 0;
// This will not work!!
if (&life == &lifemax)
&temp = 1;
}
Correction:
void talk(void)
{
int &temp = 0;
// This will not work if you're hurt!!
if (&life == &lifemax)
&temp = 1;
}
I can't remember ever running into a problem with variables and no curly braces, despite not having used them for many years. Putting them on the same line is a different story, though, that won't work nearly as always.

DinkDude was quoting the DinkC reference, but the DinkC reference lies.
DinkC reference example:
void talk(void)
{
int &temp = 0;
// This will not work!!
if (&life == &lifemax)
&temp = 1;
}
Correction:
void talk(void)
{
int &temp = 0;
// This will not work if you're hurt!!
if (&life == &lifemax)
&temp = 1;
}
I can't remember ever running into a problem with variables and no curly braces, despite not having used them for many years. Putting them on the same line is a different story, though, that won't work nearly as always.
You may be right, but just a suggestion.
As Sparrohawk said:
"About the curly brackets, I think it's like Someone and DD95 say, that you can't set a variable that way. It works usually, but with a chance of screwing up."
Metatarasal, have you tried doing something like this:
if (&crap == 0)
&duck += 1;
I think that is what the DinkC Reference means.
But please, correct me if I'm wrong.
As Sparrohawk said:
"About the curly brackets, I think it's like Someone and DD95 say, that you can't set a variable that way. It works usually, but with a chance of screwing up."
Metatarasal, have you tried doing something like this:
if (&crap == 0)
&duck += 1;
I think that is what the DinkC Reference means.
But please, correct me if I'm wrong.
Yep, I have tried doing that. Check the journalbutton in The Scourger, it works like a dream...
Well, looks like the DinkC Reference needs some work.
But, I think I'll still stick to what the reference says. You never know, it could just be an occasional bug.

But, I think I'll still stick to what the reference says. You never know, it could just be an occasional bug.
It's probably long fixed since some version of Dink, who knows maybe even in 1.07!
this script doesnt work cant figure out why just keeps killing me
whats going wrong here
//script for hole of death
void main( void )
{
sp_touch_damage(¤t_sprite, -1);
sp_nohit(¤t_sprite, 1);
sp_sound(64, 22050, 0, ¤t_sprite, 1);
}
void talk( void )
{
say("Hmmm, I wonder where this hole leads?", 1);
}
void touch( void )
{
int &rand = random(4, 1);
if (&rand == 2)
{
//Take Dink to treasure room
sp_touch_damage(¤t_sprite, 0);
script_attach(1000);
fade_down();
wait(200);
&player_map = 224;
sp_x(1, 300);
sp_y(1, 220);
load_screen();
draw_screen();
draw_status();
fade_up();
say("Looks like I choose the right hole!", 1);
&boat = 10;
unfreeze(1);
kill_this_task();
else
{
//Kill Dink off
sp_touch_damage(¤t_sprite, 0);
freeze(1);
script_attach(1000);
playsound(69, 11025, 0, 0, 0);
fade_down();
wait(4000);
&life = 0;
wait(200);
&player_map = 416;
sp_x(1, 315);
sp_y(1, 220);
load_screen();
draw_screen();
draw_status();
wait(200);
playsound(53, 22050, 0, 0, 0);
fade_up();
unfreeze(1);
kill_this_task();
return;
}
}
whats going wrong here
//script for hole of death
void main( void )
{
sp_touch_damage(¤t_sprite, -1);
sp_nohit(¤t_sprite, 1);
sp_sound(64, 22050, 0, ¤t_sprite, 1);
}
void talk( void )
{
say("Hmmm, I wonder where this hole leads?", 1);
}
void touch( void )
{
int &rand = random(4, 1);
if (&rand == 2)
{
//Take Dink to treasure room
sp_touch_damage(¤t_sprite, 0);
script_attach(1000);
fade_down();
wait(200);
&player_map = 224;
sp_x(1, 300);
sp_y(1, 220);
load_screen();
draw_screen();
draw_status();
fade_up();
say("Looks like I choose the right hole!", 1);
&boat = 10;
unfreeze(1);
kill_this_task();
else
{
//Kill Dink off
sp_touch_damage(¤t_sprite, 0);
freeze(1);
script_attach(1000);
playsound(69, 11025, 0, 0, 0);
fade_down();
wait(4000);
&life = 0;
wait(200);
&player_map = 416;
sp_x(1, 315);
sp_y(1, 220);
load_screen();
draw_screen();
draw_status();
wait(200);
playsound(53, 22050, 0, 0, 0);
fade_up();
unfreeze(1);
kill_this_task();
return;
}
}
this doesnt work either
void main (void)
{
loop:
if (&boss > 0)
{
fade_down();
sp_x(1, 320);
sp_y(1, 200);
sp_dir(1, 8);
&player_map = 180;
load_screen();
fade_up();
draw_screen();
draw_status();
kill_this_task();
goto loop;
}
}
void main (void)
{
loop:
if (&boss > 0)
{
fade_down();
sp_x(1, 320);
sp_y(1, 200);
sp_dir(1, 8);
&player_map = 180;
load_screen();
fade_up();
draw_screen();
draw_status();
kill_this_task();
goto loop;
}
}
High speed answers
I should be in bed.
//fixed hole of death
void touch( void )
{
//put this here then you only have to do it once
sp_touch_damage(¤t_sprite, 0);
//same here
freeze(1);
int &rand = random(4, 1);
if (&rand == 2)
{
//Take Dink to treasure room
script_attach(1000);
fade_down();
wait(200);
&player_map = 224;
sp_x(1, 300);
sp_y(1, 220);
load_screen();
draw_screen();
//draw_status(); unnecessary
fade_up();
say("Looks like I choose the right hole!", 1);
&boat = 10;
unfreeze(1);
kill_this_task();
}
//forgot above close bracket
//else - unnecessary, as the following will only happen
//if the above doesn't happen.
//Kill Dink off
script_attach(1000);
playsound(69, 11025, 0, 0, 0);
fade_down();
wait(4000);
&life = 0;
//Dink dies! This may be killing your script.
//Safer to make him invisible and play his death animation
//with a new sprite maybe?
wait(200);
&player_map = 416;
sp_x(1, 315);
sp_y(1, 220);
load_screen();
draw_screen();
//draw_status();
wait(200);
playsound(53, 22050, 0, 0, 0);
fade_up();
unfreeze(1);
kill_this_task();
}
Ok I hope this works now!

I should be in bed.
//fixed hole of death
void touch( void )
{
//put this here then you only have to do it once
sp_touch_damage(¤t_sprite, 0);
//same here
freeze(1);
int &rand = random(4, 1);
if (&rand == 2)
{
//Take Dink to treasure room
script_attach(1000);
fade_down();
wait(200);
&player_map = 224;
sp_x(1, 300);
sp_y(1, 220);
load_screen();
draw_screen();
//draw_status(); unnecessary
fade_up();
say("Looks like I choose the right hole!", 1);
&boat = 10;
unfreeze(1);
kill_this_task();
}
//forgot above close bracket
//else - unnecessary, as the following will only happen
//if the above doesn't happen.
//Kill Dink off
script_attach(1000);
playsound(69, 11025, 0, 0, 0);
fade_down();
wait(4000);
&life = 0;
//Dink dies! This may be killing your script.
//Safer to make him invisible and play his death animation
//with a new sprite maybe?
wait(200);
&player_map = 416;
sp_x(1, 315);
sp_y(1, 220);
load_screen();
draw_screen();
//draw_status();
wait(200);
playsound(53, 22050, 0, 0, 0);
fade_up();
unfreeze(1);
kill_this_task();
}
Ok I hope this works now!
Put goto loop; outside the if statement (other side of the curly bracket).
You will also need a wait(100) inside the loop otherwise the game will crash, needing ctrl+alt+del to get out. The length of the wait doesn't really matter.
Also, you don't need draw_status() when changing screen, only if you did something that affects the status bar like arming a weapon.
You will also need a wait(100) inside the loop otherwise the game will crash, needing ctrl+alt+del to get out. The length of the wait doesn't really matter.
Also, you don't need draw_status() when changing screen, only if you did something that affects the status bar like arming a weapon.
i got the fire sword graphics yesterday and i was wondering how i would get it to burn down a tree like a fireball?