Evidently, they are integers by default. The best I can do is to set the value as a float during runtime. So how do you put it in the code that you want a specific alterable value to be a float and not a int?
Printable View
Evidently, they are integers by default. The best I can do is to set the value as a float during runtime. So how do you put it in the code that you want a specific alterable value to be a float and not a int?
For example, change 3 to 3.0
If you want an entire expression to be evaluated as a float, change all numbers like 2 to 2.0, and add 0.0+ to the beginning of the expression.
Note that properties cannot be set to floats in the editor. You have to set them as floats at start of frame.
So something like
Start of frame
-> Set blah("Active") to 0.0
would work?
In general you need to "tell" the expression evaluator when you want to use a float.
Some examples are:
Set counter to: (value("Counter")+0.0)/100
Set counter to: value("Counter")/100.0
However if a variable has been set to be a float, I think that it in expressions will work without those tricks.
You could do:
start of frame: Set alterable value A to = alterable value A + 0.0
- and then use it in expressions. This has a serious drawback though. If you at some other point in your code set the variable to an integer you are back with the previous problem.
So a rule of thumb, if you need to use floats in some way in your expression evaluation to be sure that your calculations will be treated as floats (see the first two examples)
Yes, but since it simplifies to 0, it will be stored as an integer. Basically, MMF2 uses integers unless you or it needs to use floats.
EDIT: Andos half-beat me.
Well, I've got alterable value d as the integer 144 initially. The game says:
Always
-> Add (Step*1.5)+1.0 to Alterable Value D("Active 5")
When I play it with Step as 2, however, Alterable Value D remains at 144. It only begins to change when I manually change it to a float with the debugger.
The 'Add' action only works in integers sadly. I don't know if this is intended or a bug.
Use:
Set alterable value D to:
Alterable value D + (Step*1.5)+1.0
I was pretty sure that the "Add" integer bug was fixed at some point... unless it's the demo, perhaps?
As I said, the event works fine when Alterable Value D is already a float.Quote:
Originally Posted by Andos
I thought you could only get a TGF2 demo.Quote:
Originally Posted by DavidN