more problems
im supposed to create a trader and make the sprite(not the trader) count the no. of times i hit it
whats wrong with the script?
void main(void)
{
int &a;
&a=0;
int&trader=create_sprite(300,150,0,381,1);
}
void talk(void)
{
freeze(1);
freeze(¤t_sprite);
say_stop("Why did you call me?",1)
say_stop("`1Can you do me a favour?",¤t_sprite);
say_stop("What now?",1);
say_stop("`1........",¤t_sprite);
say_stop("Ok ok what do i have to do?",1);
unfreeze(¤t_sprite);
unfreeze(1);
}
void hit(void)
{
&a+=1;
say_stop("ok",¤t_sprite);
say_stop("u hit me &a times ^^",¤t_sprite);
}
whats wrong with the script?
void main(void)
{
int &a;
&a=0;
int&trader=create_sprite(300,150,0,381,1);
}
void talk(void)
{
freeze(1);
freeze(¤t_sprite);
say_stop("Why did you call me?",1)
say_stop("`1Can you do me a favour?",¤t_sprite);
say_stop("What now?",1);
say_stop("`1........",¤t_sprite);
say_stop("Ok ok what do i have to do?",1);
unfreeze(¤t_sprite);
unfreeze(1);
}
void hit(void)
{
&a+=1;
say_stop("ok",¤t_sprite);
say_stop("u hit me &a times ^^",¤t_sprite);
}
Make sure you place spaces at some places:
&a=0; is not the same as &a = 0;
In the same way int&trader=create_sprite(300,150,0,381,1); is not the same as int &trader = create_sprite(300,150,0,381,1);
Similar again for &a+=1;
Also, a semicolon is missing after say_stop("Why did you call me?",1)
&a=0; is not the same as &a = 0;
In the same way int&trader=create_sprite(300,150,0,381,1); is not the same as int &trader = create_sprite(300,150,0,381,1);
Similar again for &a+=1;
Also, a semicolon is missing after say_stop("Why did you call me?",1)
I don't completely get what you're trying to do. What sprite is this script attached to?
And what exactly is going wrong? Is it saying the stuff but not counting? Aside from a missing space between int and &trader I don't see anything wrong with it at first sight. Oh, but you missed a semicolon after the first say_stop line.
And what exactly is going wrong? Is it saying the stuff but not counting? Aside from a missing space between int and &trader I don't see anything wrong with it at first sight. Oh, but you missed a semicolon after the first say_stop line.
its saying 0 whenever i hit it XD
i mean its not &a is not increasing
i mean its not &a is not increasing
its talking perfectly
but hit part is not working
i tried the spaces as well
but hit part is not working
i tried the spaces as well
And is it saying these lines?
I think the game normally keeps track of variables defined in its main procedure as long as you don't switch screens. So I'm actually confused about this not working.
I guess it always says: "U hit me 0 times"?
say_stop("ok",¤t_sprite); say_stop("u hit me &a times ^^",¤t_sprite);
I think the game normally keeps track of variables defined in its main procedure as long as you don't switch screens. So I'm actually confused about this not working.
I guess it always says: "U hit me 0 times"?
The fun part is where it should never say 0, even after screenchange, since it is incremented before the calls to say_stop().
ok as Metatarasal said the error most likely is in forgotten spaces with the counters this way the engine sees the whole line as a command instead of a command with specifics told
He already said he tried removing the spaces without success. And like Magicman says, since it says "0" the variable is just not being changed to begin with.
But as it says 0 it means that the variable is declared correctly. Apparently it's not incrementing properly.
I just tested the script after adding the suggestions I made and it runs fine for me... Just to be sure I'll post the script again here:
It helps to put some freeze commmands in the void hit procedure though...
I just tested the script after adding the suggestions I made and it runs fine for me... Just to be sure I'll post the script again here:
void main(void) { int &a; &a = 0; int &trader = create_sprite(300,150,0,381,1); } void talk(void) { freeze(1); freeze(¤t_sprite); say_stop("Why did you call me?",1); say_stop("`1Can you do me a favour?",¤t_sprite); say_stop("What now?",1); say_stop("`1........",¤t_sprite); say_stop("Ok ok what do i have to do?",1); unfreeze(¤t_sprite); unfreeze(1); } void hit(void) { &a += 1; say_stop("ok",¤t_sprite); say_stop("u hit me &a times ^^",¤t_sprite); }
It helps to put some freeze commmands in the void hit procedure though...
its working now after i replaced my script with metatarasal's
i guess the problem was due to the spaces
i tried &a++ as well but it didnt work as well
i guess dink c needs spaces for incrementing values
i guess the problem was due to the spaces
i tried &a++ as well but it didnt work as well
i guess dink c needs spaces for incrementing values
I thought you said you tried with the spaces before?
Anyway, it's good that you got it working^^ The ++ and -- operators don't work in DinkC, a shame I know

Anyway, it's good that you got it working^^ The ++ and -- operators don't work in DinkC, a shame I know

well maybe he still missed some spaces(why i reminded him be rephrasing meta's words)
haha my bad XD