RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

[solved] decimals?

Started by shintashi, March 22, 2011, 05:17:57 PM

0 Members and 1 Guest are viewing this topic.

shintashi

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?

shintashi

#1
integer(blah values)... sorry. forgot.

modern algebra

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.