Having Decimal Number Problems

-Solace-

Villager
Member
Joined
Dec 15, 2019
Messages
13
Reaction score
1
First Language
Arabic
Primarily Uses
RMMV
I have made the following formula for gold drops from enemies with Yanfly's Enemy Base Parameters plugin:
Code:
gold = 100 * Math.pow(1.2, level - 1) - (level * 2);
The problem is that the resulting number is usually a float number with decimals thanks to the exponent. The first thing I tried was to add ".to_i" and "Integer()" but to no avail; since the value completely disappears from the item drop screens.

How can I fix that problem without removing the exponent?
 

Maliki79

Veteran
Veteran
Joined
Mar 13, 2012
Messages
797
Reaction score
350
First Language
English
Primarily Uses
N/A
Why not wrap the whole formula in Math.floor?

Code:
gold = Math.floor(100 * Math.pow(1.2, level - 1) - (level * 2));
 

-Solace-

Villager
Member
Joined
Dec 15, 2019
Messages
13
Reaction score
1
First Language
Arabic
Primarily Uses
RMMV
Oh... Solved. xD
I'm sorry, I'm just terrible with programming languages. I only started dealing with them upon using RPG Maker. Just searched up what the Math.floor() function does. I will probably use that very often later on.

Thank you SO MUCH for your valuable help. Whenever I use the function in any code in the future, I will be remembering you. xD
 

Maliki79

Veteran
Veteran
Joined
Mar 13, 2012
Messages
797
Reaction score
350
First Language
English
Primarily Uses
N/A
LoL No worries.
I learned from these forums as well!
Glad I'll always have a place in your programming heart! ;-)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,038
Members
137,568
Latest member
invidious
Top