The Dink Network

i could use some help

May 28th 2008, 09:55 PM
pq_skull.gif
im creating my first game and ineed to make a count down timer of some sort can anyone help
May 28th 2008, 10:56 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
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();
}
May 28th 2008, 11:49 PM
pq_skull.gif
what does &num do
and script_attach(1000);
May 28th 2008, 11:52 PM
pq_skull.gif
by the way thanks
May 29th 2008, 02:53 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
&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.
May 29th 2008, 03:28 AM
fairy.gif
Someone
Peasant He/Him Australia
 
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);
}
May 29th 2008, 04:15 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
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; }
}
May 29th 2008, 06:50 AM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
I completely forgot about that It did work though. Go figure.
May 29th 2008, 09:44 AM
anon.gif
metatarasal
Ghost They/Them
 
No, you're wrong.

Even the original game has this set of lines in most monsters:

int &hold = sp_editor_num(&current_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...
May 29th 2008, 11:09 AM
dinkdead.gif
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!", &current_sprite);
May 29th 2008, 07:03 PM
spike.gif
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.
May 30th 2008, 01:56 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
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.
May 30th 2008, 08:38 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Yep, I have tried doing that. Check the journalbutton in The Scourger, it works like a dream...
May 30th 2008, 11:38 PM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
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.
May 31st 2008, 02:26 PM
slimeb.gif
DaVince
Peasant He/Him Netherlands
Olde Time Dinkere 
It's probably long fixed since some version of Dink, who knows maybe even in 1.07!
June 2nd 2008, 08:33 PM
pq_skull.gif
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(&current_sprite, -1);
sp_nohit(&current_sprite, 1);
sp_sound(64, 22050, 0, &current_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(&current_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(&current_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;
}

}

June 2nd 2008, 08:41 PM
pq_skull.gif
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;
}
}

June 2nd 2008, 08:57 PM
dinkdead.gif
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(&current_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!
June 2nd 2008, 09:05 PM
dinkdead.gif
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.
June 9th 2008, 08:40 PM
pq_skull.gif
i got the fire sword graphics yesterday and i was wondering how i would get it to burn down a tree like a fireball?
June 17th 2008, 08:43 PM
pq_skull.gif
dont worry figured it out