A Scrip problem
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(¤t_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?
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(¤t_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?
if (&key == 1)
{
{
I'm guessing the extra { is causing you problems, as the if statements aren't being closed now.
{
{
I'm guessing the extra { is causing you problems, as the if statements aren't being closed now.
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.
void talk( void )
{
if (&key == 1)
{
//code
}
if (&key == 2)
{
//code
}
}
This is the correct amount and position of the braces.
I used that, but now he opens the door, even the "&key" isn't 2.
???
Otherwise it is fine.
???
Otherwise it is fine.
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.
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.
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.
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.
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?
Oh, and could you also post the corrected version of your code?
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(¤t_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.
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(¤t_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.
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.
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.
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.
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.









