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.
[solved] decimals?

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 82
We learn by living...
so ive got a script that looks like this:


Code: [Select]
#===============================================================
#shintashi's EXP Division module
    @xpx = 0
    for i in 0...$game_party.actors.size
    actor = $game_party.actors[i]
      if actor.hp == 0
        @xpx += 1
        end
      end
   @basexp = 4.0 / ($game_party.actors.size - @xpx)
#---------------------------------------------------------------     
        exp += (enemy.exp * @basexp) #added by shintashi
#===============================================================


This is basically another way of saying "if you kill the monster by yourself you get full exp. Otherwise, you get a cut". But the problem I'm running into is this:

A:
Code: [Select]
   @basexp = 4.0 / ($game_party.actors.size - @xpx)



verses this:

B:
Code: [Select]
   @basexp = 4 / ($game_party.actors.size - @xpx)

A produces figures like 1333.33333333333333 exp awards, while B produces figures like 1000 even. My goal is to produce 1333 without decimals, and without losing the +333 experience points. Help?
« Last Edit: March 22, 2011, 07:05:50 PM by shintashi »

***
Rep:
Level 82
We learn by living...
integer(blah values)... sorry. forgot.
« Last Edit: March 22, 2011, 09:32:17 PM by shintashi »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Yeah, sounds like you solved it. You can also use .truncate or simply .to_i, so 133.33333.truncate would return 133. You can also use .ceil, .floor, or .round if you wanted to keep it as a float.