script keeps getting 0 for an int but i have told it to ad one to the int before

Started by matt, Tue 23/12/2008 22:54:52

Previous topic - Next topic

matt

this is the script :
distance++;
int help1 = int1/distance*size_of_the_object;

int1, distance and size_of_the_object are all ints

distance keeps coming out as zero and i don't know why.
i cheaked that distance couldn't be a negitve.

please help.

what?

Pumaman

If distance was 0, that line would be crashing with a divide by zero error.

How do you know that distance is 0? Have you placed a line like this before and after the "distance++" line?
Display("distance = %d", distance);

Dualnames

int help1 = int1/distance*size_of_the_object;

distance keeps coming out as zero and i don't know why.

I do know why.

int help1 = int1/distance*size_of_the_object;

First which math should happen first?
this?
int help1 = (int1/distance)*size_of_the_object;
or this:
int help1 = int1/(distance*size_of_the_object);


Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

matt


what?

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

matt

Thanks but the distance is calculated by the players pos and the object pos

what?

Dualnames

There's a probability(i'm just guessing) that the distance integer doesn't get a value before the if statement.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

matt


what?

SMF spam blocked by CleanTalk