The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: shintashi on March 22, 2011, 05:17:57 PM

Title: [solved] decimals?
Post by: shintashi on March 22, 2011, 05:17:57 PM
so ive got a script that looks like this:



#===============================================================
#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:

   @basexp = 4.0 / ($game_party.actors.size - @xpx)




verses this:

B:

   @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?
Title: [solved] decimals?
Post by: shintashi on March 22, 2011, 07:05:34 PM
integer(blah values)... sorry. forgot.
Title: Re: [solved] decimals?
Post by: modern algebra on March 23, 2011, 12:19:13 AM
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.