The Dink Network

more problems

May 4th 2011, 06:32 AM
duckdie.gif
welovefudge
Peasant He/Him Russia
I hope life isn’t a joke, because I don’t get it. 
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(&current_sprite);
say_stop("Why did you call me?",1)
say_stop("`1Can you do me a favour?",&current_sprite);
say_stop("What now?",1);
say_stop("`1........",&current_sprite);
say_stop("Ok ok what do i have to do?",1);

unfreeze(&current_sprite);
unfreeze(1);
}
void hit(void)
{
&a+=1;
say_stop("ok",&current_sprite);
say_stop("u hit me &a times ^^",&current_sprite);
}
May 4th 2011, 06:47 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
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)
May 4th 2011, 06:48 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
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.

May 4th 2011, 06:52 AM
duckdie.gif
welovefudge
Peasant He/Him Russia
I hope life isn’t a joke, because I don’t get it. 
its saying 0 whenever i hit it XD
i mean its not &a is not increasing
May 4th 2011, 06:55 AM
duckdie.gif
welovefudge
Peasant He/Him Russia
I hope life isn’t a joke, because I don’t get it. 
its talking perfectly
but hit part is not working
i tried the spaces as well
May 4th 2011, 07:57 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
And is it saying these lines?

say_stop("ok",&current_sprite);
say_stop("u hit me &a times ^^",&current_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"?
May 4th 2011, 11:27 AM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
The fun part is where it should never say 0, even after screenchange, since it is incremented before the calls to say_stop().
May 4th 2011, 12:21 PM
knights.gif
merder
Peasant He/Him Netherlands
The Voice in the back of your head! 
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
May 4th 2011, 12:59 PM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
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.
May 4th 2011, 01:59 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
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:

void main(void)
{
int &a;
&a = 0;
int &trader = create_sprite(300,150,0,381,1);
}

void talk(void)
{
freeze(1);
freeze(&current_sprite);
say_stop("Why did you call me?",1);
say_stop("`1Can you do me a favour?",&current_sprite);
say_stop("What now?",1);
say_stop("`1........",&current_sprite);
say_stop("Ok ok what do i have to do?",1);

unfreeze(&current_sprite);
unfreeze(1);
}
void hit(void)
{
&a += 1;
say_stop("ok",&current_sprite);
say_stop("u hit me &a times ^^",&current_sprite);
}

It helps to put some freeze commmands in the void hit procedure though...
May 5th 2011, 03:39 AM
duckdie.gif
welovefudge
Peasant He/Him Russia
I hope life isn’t a joke, because I don’t get it. 
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
May 5th 2011, 04:22 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
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
May 5th 2011, 05:20 AM
knights.gif
merder
Peasant He/Him Netherlands
The Voice in the back of your head! 
well maybe he still missed some spaces(why i reminded him be rephrasing meta's words)
May 5th 2011, 05:37 AM
duckdie.gif
welovefudge
Peasant He/Him Russia
I hope life isn’t a joke, because I don’t get it. 
haha my bad XD
May 5th 2011, 07:32 PM
knights.gif
merder
Peasant He/Him Netherlands
The Voice in the back of your head! 
no problem from mistakes you can learn and we are here to help