RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Variables hold decimals?

0 Members and 1 Guest are viewing this topic.

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
Oh, if it needs to all be on one line, then maybe it might not work because the variables I'm using are 3 digits long and not 1, so without spaces the line reads all the way across then overlaps to a new line. With spaces, it'll place one variable on a line then put the next variable on a new line below it. Either way, doing it with .to_f then .to_i worked with spaces if they were on more than one line. I'll test this further.

****
Rep:
Level 83
Maybe its just my bad luck that is causing it to give me an error. I don't know.
Let me know the results, and maybe I can find a shorter way. lol

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
I found that .round has to be connected to the variable without being split, so having code on separate lines is fine as long as the code isn't cut in half somewhere and continued on a new line.

EDIT: I have this stupid bug now.
Code: [Select]
$game_variables[552]/=100
$game_variables[552]+=1
$game_variables[548]*=$game_variables[552]
$game_variables[548]=
$game_variables[548].round

[552] = the Loan's interest rate. At the moment, it equals 25. [552]=25
[548] = how much money you withdraw in a loan to borrow. (Example: 10000G)

So what should be happening is:
25/100 = .25
.25+1 = 1.25
10000*1.25 = 12500
(Then if it happens to be a decimal, it'll round it.)

However, what's happening is that the result remains the amount you withdraw without adding on the interest. So in this example, the result ends up staying 10000 instead of becoming 12500 like it should be. It might be caused by the .round, but I'm not sure. Does .round only round decimals, or does it round whole numbers up to like the next whole number? Like rounding 12500 to the nearest 10 thousand which remains 10000 instead of printing 12500. :/

I'll run a test quickly with the .to_f and .to_i and see if that makes a difference because as far as I'm concerned, .to_f makes it round decimals. We'll see.

EDIT2:
Well I checked it, and changing .round to .to_f and .to_i didn't make a difference, so I decided I'd remove the math. I had it there so that the player could remotely change variable[552] to fit what they wanted for an interest rate. So if [552]=25, then the interest rate would be 25% by the math that was done. However, the math isn't doing anything at all and apparently ends up equaling 1 or something, then 1*[548] would still equal [548]. There lies the problem.
Anyways, I removed the option for that variable and instead changed it to a static number, so I made it directly like:
Code: [Select]
$game_variables[548]*=1.25
Now doing this, in the end it works out just how it's supposed to, it's just when there was that math involved that it didn't work.
Can you take a look at the math above in my previous edit and see what might be the cause?
« Last Edit: November 15, 2009, 08:34:50 PM by grafikal »

****
Rep:
Level 83
Your problem is quite simple. You forgot to put ".00" after the 100.
It should look like this.
Code: [Select]
$game_variables[552]/=100[b].00[/b]
$game_variables[552]+=1
$game_variables[548]*=$game_variables[552]
$game_variables[548]=
$game_variables[548].round

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
OH DAMNIT! dirty double 0's. I used to love them so much. They used to be apart of my name :( now they betray me.

Well, as soon as I get those in there and re-create all of those variables I deleted and fix it up again, I'll upload the project (FINALLY) and I'll have fully functioning Banking Event System that is as easy to use as copy/paste a few common events and map events. Those decimals really cut down on a lot of work and added a LOT of easy customization.
« Last Edit: November 15, 2009, 09:42:52 PM by grafikal »

****
Rep:
Level 83
Haha. Yea. Its just a little oversight. Happens to me all the time...usually a spelling error though. Hope it works now