Jump to content
mjshi

Item Sell Price

Recommended Posts

Okay, so in Scene_Shop I found this:

  #--------------------------------------------------------------------------
  # * Get Sale Price
  #--------------------------------------------------------------------------
  def selling_price
    @item.price / 2
  end
end
And realizing that I wanted to make selling back items worth more than half price, I proceeded to change it to this:

  #--------------------------------------------------------------------------
  # * Get Sale Price
  #--------------------------------------------------------------------------
  def selling_price
    @item.price * 0.75
  end
end
But what ended up happening was that upon selling back a "potion" worth 50 G, it returned a float number of 37.5 G

Is there any way to "round" a float number in Ruby code?

 

EDIT: no need to trouble about rounding "up" or "down", just always round up xD

 

EDIT 2: I found that even when multiplying "50" by 0.8, which would give a whole number, still returns a float with a ".0" at the end. So.. float to int conversion, anyone? .-.

Edited by innovation

Share this post


Link to post
Share on other sites

Strange that when I use R_Valkyrie's suggestion, an item at 50 G comes out to 36 (50/4 = 12.5, probably rounded to 12, then multiplied by 3) whereas Glasses's suggestion makes it come out as a 37. Anyway, Thanks to both of you!

Share this post


Link to post
Share on other sites

@ Soulpour777: That's not quite what I was looking for, and I've already found the answer to my question. Thank you for responding though! This thread can be closed now.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted