Page 1 of 1

small code problem

PostPosted: Sat Dec 22, 2007 9:02 pm
by Zehper48
ok i have a problem with my code, here it is
Code: Select all
no1.textNumber = goalxpV - currentxpV /55;


ok, when i do this, my text number doesnt get divided by 55, it gets turned into a realy weird number
and goalxpV = 388 and currentxpV = 0 in this case,
what should i do differently? are there any obvious mistakes..


Thanks!

Re: small code problem

PostPosted: Sat Dec 22, 2007 10:58 pm
by MrScience101
Any way to post your code? It could be that the variables are integers, or there is simply a silly typo somewhere in the code. From the above statement, there is just not enough info to come to a good conlcusion.

Re: small code problem

PostPosted: Sun Dec 23, 2007 12:40 am
by Game A Gogo
it gives out 7.05454545454... right?
well, let me tell ya why in a simple thing

388 - 0 /55
=(388-0)/55
=388/55

so you see, you need to do this

no1.textNumber=goalxpV-(currentxpV/55);

Re: small code problem

PostPosted: Sun Dec 23, 2007 5:03 pm
by Zehper48
i want it to give me 7.05454545454
but it gives me 388
some how in
no1V = goalxpV - currentxpV / 55; (i changed it to no1V which is a variable and i made no1.textNumber = to no1V)
the result of goalxpV - currentxpV isn't getting divided by 55

i dont know why, its confusing


*SUPER EDIT*
yay i found the problem!!! the problem was this
no1V =goalxpV - currentxpV / 55;

it should be no1V = (goalxpV - currentxpV) / 55; with the (,) to get the result!

i have to remeber Order of Operations =p

im happy now!

thx

Re: small code problem

PostPosted: Sun Dec 30, 2007 7:57 am
by Zehper48
This is kind of another problem, but i didnt want to make a new topic but heres my code
Code: Select all
if (findV==1)
{
    no1.textNumber = (goalxpV - currentxpV) / 55;
    no2.textNumber = (goalxpV - currentxpV) / 75;
    no3.textNumber =  0;
    no4.textNumber =  0;
    no5.textNumber =  0;
    no6.textNumber =  0;
    no7.textNumber =  0;
}

this is on a mouse down left event
so i added a tempory text number to see if "findV" equaled 1, and it did, and i did same for "goalxpV" and "currentxpV"
but still when i have a mouse down left on the actor that preforms this code, guess what happens to no1.textNumber-no7.textNumber? nothing happens

any obious mistakes?





. /^--^\ /^--^\ /^--^\
. \____/ \____/ \____/
. / \ / \ / \
. | | | | | |
. \__ __/ \__ __/ \__ __/
. |^|^|^|^|^|^|^|^|^|^|^\ \^|^|^/ /^|^|^|^\ \^|^|^|^|^|^|^|^|^|^|
. | | | | | | | | | | | |\ \| |/ /| | | | |\ \| | | | | | | | | |
. | | | | | | | | | | | |/ /| |\ \| | | | |/ /| | | | | | | | | |
. | | | | | | | | | | | |\/ | | \/| | | | |\/ | | | | | | | | | |
. ###############################################################

Re: small code problem

PostPosted: Wed Jan 02, 2008 2:20 am
by Sgt. Sparky
Zehper48 wrote:This is kind of another problem, but i didnt want to make a new topic but heres my code
Code: Select all
if (findV==1)
{
    no1.textNumber = (goalxpV - currentxpV) / 55;
    no2.textNumber = (goalxpV - currentxpV) / 75;
    no3.textNumber =  0;
    no4.textNumber =  0;
    no5.textNumber =  0;
    no6.textNumber =  0;
    no7.textNumber =  0;
}

this is on a mouse down left event
so i added a tempory text number to see if "findV" equaled 1, and it did, and i did same for "goalxpV" and "currentxpV"
but still when i have a mouse down left on the actor that preforms this code, guess what happens to no1.textNumber-no7.textNumber? nothing happens

any obious mistakes?

I don't see any obvious problems with the code.
But why are you using 7 different actors to display variables?

Re: small code problem

PostPosted: Wed Jan 02, 2008 6:36 am
by Zehper48
the code is acctualy longer , finvV =1,2,3,4, all the way to 16.

for each number the no1-no7.textNumber equal somthing different... im rly confused, im just going to have to play around with it i guess,



****EDIT***** umm, i found out what was wrong but i feel rly stupid, i have a uhmm filled region in the way. dnt laugh, lol idont care if you laugh lol its pretty funny~

Re: small code problem

PostPosted: Wed Jan 02, 2008 6:54 pm
by Sgt. Sparky
Zehper48 wrote:the code is acctualy longer , finvV =1,2,3,4, all the way to 16.

for each number the no1-no7.textNumber equal somthing different... im rly confused, im just going to have to play around with it i guess,



****EDIT***** umm, i found out what was wrong but i feel rly stupid, i have a uhmm filled region in the way. dnt laugh, lol idont care if you laugh lol its pretty funny~


*doesn't laugh* :)
Don't worry, I have done a whole lot of things like that before. xD