The Dink Network

A Scrip problem

September 4th 2007, 10:33 AM
custom_skull.gif
skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Hey I need help here.

void talk( void )
{
if (&key == 1)
{
{
freeze(1);
say_stop("`3Hmm.. this door is locked but... how?", 1);
sp_dir(1, 2);
say_stop("`3I wonder what's behind it?", 1);
unfreeze(1);
}
if (&key == 2)
{
{
freeze(1);
say_stop("`3Hmm.. this door is locked but... how?", 1);
sp_dir(1, 2);
say_stop("`3I wonder what's behind it?", 1);
sp_dir(1, 6);
say_stop("`3This key might...", 1);
sp_nodraw(&current_sprite, 1);
say_stop("`3Open it!", 1);
fade_down();
sp_active(&kill, 0);
wait(500);
script_attach(1000);
fill_screen(0);
&player_map = 283;
sp_x(1, 355);
sp_y(1, 185);
sp_dir(1, 6);
load_screen(34);
draw_screen();
fade_up();
unfreeze(1);
}
---
That's my script. But when I tru to talk to the door, Dink says nothing. and When I got the key. He still doesn't say nothing.

Any help? Did I do something w-r-o-n-g?
September 4th 2007, 10:47 AM
maidenb.gif
Sharp
Peasant She/Her Finland
 
if (&key == 1)
{
{

I'm guessing the extra { is causing you problems, as the if statements aren't being closed now.
September 4th 2007, 10:59 AM
custom_skull.gif
skull
Peasant He/Him Finland bloop
A Disembodied Sod 
No. It still doesn't work!
September 4th 2007, 11:51 AM
slimeb.gif
DaVince
Peasant He/Him Netherlands
Olde Time Dinkere 
I'm counting the braces and I see 5 opening braces and only 2 closing braces. The amount of opening braces has to be the same amount as the amount of closing braces, or it'll be wrong.

void talk( void )
{
if (&key == 1)
{
//code
}

if (&key == 2)
{
//code
}
}

This is the correct amount and position of the braces.
September 4th 2007, 12:33 PM
custom_skull.gif
skull
Peasant He/Him Finland bloop
A Disembodied Sod 
I used that, but now he opens the door, even the "&key" isn't 2.

???

Otherwise it is fine.
September 4th 2007, 01:14 PM
slimeb.gif
DaVince
Peasant He/Him Netherlands
Olde Time Dinkere 
Hm, could you post the code related to giving values to the &key variable?

EDIT: btw, making Dink say "How is the door locked?" is a bit weird, because obviously it's a lock of some kind that keeps a door locked.
September 4th 2007, 01:22 PM
custom_skull.gif
skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Yes, but, they are in mines, and that's the thing. Who would have put a door inside the mines? Hmmm...

Uhh... could you explain a little better that code thingy. Y'know, I'm not anykind of expert at computer. And I'm a finn. So, I don't understand much.
September 4th 2007, 01:26 PM
slimeb.gif
DaVince
Peasant He/Him Netherlands
Olde Time Dinkere 
Just the code related to anything that refers to or changes the &key variable... You showed us the part where it's referred to and compared with (the key == 1 stuff), but where are you SETTING the variable to values (make_global_int() function and whereever you give it a new value)? Show me the code around that part, it might set it to 2 too soon or something.

Oh, and could you also post the corrected version of your code?
September 4th 2007, 01:44 PM
custom_skull.gif
skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Here we go. I hope this is right!

make_global_int("&key", 0);

That's the glpbal int.

Corrected version:
void talk( void )
{
if (&key == 1)
{
freeze(1);
say_stop("`3Hmm.. this door is locked but... how?", 1);
sp_dir(1, 2);
say_stop("`3I wonder what's behind it?", 1);
unfreeze(1);
}
if (&key == 2)
{
{
freeze(1);
say_stop("`3Hmm.. this door is locked but... how?", 1);
sp_dir(1, 2);
say_stop("`3I wonder what's behind it?", 1);
sp_dir(1, 6);
say_stop("`3This key might...", 1);
sp_nodraw(&current_sprite, 1);
say_stop("`3Open it!", 1);
fade_down();
sp_active(&kill, 0);
wait(500);
script_attach(1000);
fill_screen(0);
&player_map = 283;
sp_x(1, 355);
sp_y(1, 185);
sp_dir(1, 6);
load_screen(34);
draw_screen();
fade_up();
unfreeze(1);
}
}

I hope those are right.

BTW: I gotta go now, so I probably don't reply in a while. Just for, so you know.
September 4th 2007, 01:56 PM
slimeb.gif
DaVince
Peasant He/Him Netherlands
Olde Time Dinkere 
The problem is simple, you still have TWO opening braces after your second condition.

Remember this:
- You only need one opening bracket after a function declaration (that's void blah()), and close it when you're done with that function.
- The exact same deal for conditions (if's).
- When you're done coding, count the amount of brackets (and the positions of them) in your code. If there are multiple in a row, or if the amount of {'s doesn't match the amount of }'s, you made a mistake somewhere.
September 5th 2007, 08:25 AM
custom_skull.gif
skull
Peasant He/Him Finland bloop
A Disembodied Sod 
No help.

He still opens the door, even my "&key" is only at 1. Plus, he opens it when it's at 2 too.

Thanks, but didn't help.
September 5th 2007, 10:23 AM
custom_skull.gif
skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Never mind. I changed the scrip into somekind different, and it works now. Thanks anyway!