Advertisement
CompanionWulf

Global Gold Comma Separators Scriptlet - RMVXA

Mar 13th, 2015
2,145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.47 KB | None | 0 0
  1. #==============================================================================
  2. # ** Global Gold Comma Separators Scriptlet - RMVXA
  3. #   © 2015, Companion Wulf
  4. #------------------------------------------------------------------------------
  5. #  Adds commas to larger numbers.
  6. #==============================================================================
  7.  
  8. #==============================================================================
  9. # ** Window_Base
  10. #==============================================================================
  11. class Window_Base < Window
  12.   #--------------------------------------------------------------------------
  13.   # * Constants to toggle commas on/off
  14.   #--------------------------------------------------------------------------
  15.   ENABLE_COMMAS = true          # Enable/disable commas
  16.   #--------------------------------------------------------------------------
  17.   # * Convert to comma
  18.   #--------------------------------------------------------------------------
  19.   def to_comma(n)
  20.     n.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # * Draw Number (Gold Etc.) with Currency Unit
  24.   #--------------------------------------------------------------------------
  25.   alias :cwac_draw_curr_val :draw_currency_value
  26.   def draw_currency_value(value, unit, x, y, width)
  27.     value = to_comma(value) if ENABLE_COMMAS
  28.     cwac_draw_curr_val(value, unit, x, y, width)
  29.   end
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement