The Daily Click ::. Forums ::. Klik Coding Help ::. Fractions in TGF2 - Troubles with Expression editor
 

Post Reply  Post Oekaki 
 

Posted By Message

Weston L



Registered
  16/12/2002
Points
  1603
17th July, 2010 at 23:56:37 -

I am making a game in TGF2 where I need to find an average.

I have the Event:
At Start of frame, set Global value Q to...

( h/(b+h))*t + ( b/(b+h))*u

Where h,b,t, and u all represent values of Counter Objects [e.g. value("CounterH")]

THE PROBLEM: If we let h=60 ; b=150 ; t=11 ; u=12
We get the expression ( 60/ (150+60) )*11 + ( 150/ (150+60) )*12 which SHOULD yield 11.71... Instead, of this number, or even the closest integer, it's setting Global Value Q to 0.

The problem is that TGF2 seems to interpret *individual fractions* as the closest integer. In my expression we start with ( 60 / 210 )*11 ; the fraction part is less than 1, so TGF2 reads it as 0. The other fraction part (150/210) is also less than 1. Therefore it becomes 0*11 + 0*12 = 0.

What should I do? Is there a special object perhaps that can store fractions as decimals?

Thanks in advance! I know it's a tricky one

 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
18th July, 2010 at 00:01:28 -

Try multiplying some of the factors by 1.0, so MMF is forced to use decimal places. For example, when you use value H, put (Value H * 1.0).

I'm not quite positive whether you need to do it to all factors.

 

  		
  		

Rob Westbrook



Registered
  25/05/2007
Points
  193

360 OwnerVIP Member
18th July, 2010 at 03:31:37 -

I really hope this gets fixed in MMF3. It's a massive pain in the proverbial...

 
There are 10 types of people in the world: Those who understand binary and those who don't.

columbo borgi :C



Registered
  07/12/2003
Points
  296

VIP Member
19th July, 2010 at 16:14:24 -


Originally Posted by Rob Westbrook
I really hope this gets fixed in MMF3. It's a massive pain in the proverbial...



this makes your game run faster :C

 
:C

Weston L



Registered
  16/12/2002
Points
  1603
23rd July, 2010 at 05:25:58 -

" Try multiplying some of the factors by 1.0, so MMF is forced to use decimal places. For example, when you use value H, put (Value H * 1.0). "

This worked! Thanks OldManClayton and all others who responded.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click