Is there a easy way to make a money counter WITH OUT using python.
For example:
$12.34 then you collect 5 cents and it added to give you $12.39
A float displays 6 zeros after the decimal place and an integer dosn’t have decimals. I’ve figured out one way but I would think there is a easier way.
PS. In the middle of learning some basic python but trying to aviod it as this is my first game and I’m trying to keep it as simple as possible.
well you could use a simple property to store the value of your money so say when the player gets a message add 5 cents it adds on 5 to the property, im not sure how to do it with decimal points thow.
Monster: If I understood correctly I done something simliar. I tried but without success.
a couple of problems If I add 20 cents to 90 cents I get 120 cents(3 decimal places) and it doesnt add one dollar to the dollars. I could work my way around this, but just checking to see if I have it right.
Ive included a blend which has my round about way and monster suggestion(which I couldn’t get to work.)
I suggest to separate money counting from the display.
These are two different thinks. If you mix them you get complex and hard to read code.
You can separate them by using different objects (recommended), or by using different states (you can have two states active at the same time).
You will see the complex logic will fall into much simpler peaces ;).
Assigning Value to Value makes not much sense didn’t it? Better assign Value to number (first Property actuator)
Enter the complete formula in the value field of the second property actuator
The second actuator should be assign mode. With add you get different results.
The third property actuator is fine as it is.
The value in Money.counter.001 does not change. Therefore it does nothing. If you need to display the initial value add an Always sensor (no Pulses) and change the controller to “OR”.
You can add a label or a currency sign just by adding it to the third property actuator or add another one. Example:
------> Property Actuator Assign Prop:Text Value:“label “+Text+” currency units”
Thanks Monster.
Just one problem which is the reason I used my round about way. It displays .01 cents as .1 Any number under 10 cents it displays as a single digit decimal (see picture).
And for some odd reason it skips counting. At .04 cents it loses a cent and then gains it back at .16 cents :eek:
(Value*100)%100 is this line removing decimal places. From my understanding multiply the value by 100 then divide by 100 and displaying the remainder.
Can’t you just use the float value in the property? .160 + .040 = .200? Then when you reach .990+.010 it would just equal 1.000, or 1.00. Or is the extra zero at the end what your trying to avoid?
As far as I know there is no format option in the Python actuator. The default format of float has 6 decimal places. Currencies are usually not expressed with such a precision ;).