SHARE
TWEET

Global Gold Comma Separators Scriptlet - RMVXA

CompanionWulf Mar 13th, 2015 (edited) 2,016 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top