Advertisement
Fomar0153

Fomar0153 - Albhed Translator 1.1

Feb 21st, 2012
1,000
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.83 KB | None | 0 0
  1. =begin
  2. Albhed Translator
  3. by Fomar0153
  4. Version 1.1
  5. ----------------------
  6. Notes
  7. ----------------------
  8. Adds an Albhed style language to your game.
  9. ----------------------
  10. Instructions
  11. ----------------------
  12. Follow the instructions in the Albhed module
  13. turn your chosen switch on to have people speak
  14. Albhed.
  15. ----------------------
  16. Change Log
  17. ----------------------
  18. 1.0 -> 1.1 Added the ability to not translate sections
  19.            of a message. Use { and } to keep part of the message untranslated.
  20.            Added the ability to have the translated text appear in another
  21.            colour.
  22. ----------------------
  23. Known bugs
  24. ----------------------
  25. None
  26. =end
  27. module Albhed
  28.  
  29.   # Id of the switch to translate the text to Albhed
  30.   ALBHED_SWITCH = 5
  31.   ALBHED_COLOR = 16 # system color
  32.  
  33.   ALBHED_CHARS = {}
  34.   # ALBHED_CHARS['letter'] = ['replacementletter', itemid to translate]
  35.   ALBHED_CHARS['a'] = ['b', 1]
  36.   ALBHED_CHARS['b'] = ['c', 1]
  37.   ALBHED_CHARS['c'] = ['d', 1]
  38.   ALBHED_CHARS['d'] = ['e', 1]
  39.   ALBHED_CHARS['e'] = ['f', 1]
  40.   ALBHED_CHARS['f'] = ['g', 1]
  41.   ALBHED_CHARS['g'] = ['h', 1]
  42.   ALBHED_CHARS['h'] = ['i', 1]
  43.   ALBHED_CHARS['i'] = ['j', 1]
  44.   ALBHED_CHARS['j'] = ['k', 1]
  45.   ALBHED_CHARS['k'] = ['l', 1]
  46.   ALBHED_CHARS['l'] = ['m', 1]
  47.   ALBHED_CHARS['m'] = ['n', 1]
  48.   ALBHED_CHARS['n'] = ['o', 1]
  49.   ALBHED_CHARS['o'] = ['p', 1]
  50.   ALBHED_CHARS['p'] = ['q', 1]
  51.   ALBHED_CHARS['q'] = ['r', 1]
  52.   ALBHED_CHARS['r'] = ['s', 1]
  53.   ALBHED_CHARS['s'] = ['t', 1]
  54.   ALBHED_CHARS['t'] = ['u', 1]
  55.   ALBHED_CHARS['u'] = ['v', 1]
  56.   ALBHED_CHARS['v'] = ['w', 1]
  57.   ALBHED_CHARS['w'] = ['x', 1]
  58.   ALBHED_CHARS['x'] = ['y', 1]
  59.   ALBHED_CHARS['y'] = ['z', 1]
  60.   ALBHED_CHARS['z'] = ['a', 1]
  61.  
  62.   def self.translate(c)
  63.     return c if ALBHED_CHARS[c.downcase].nil?
  64.     return c if $game_party.has_item?($data_items[ALBHED_CHARS[c.downcase][1]])
  65.     return ALBHED_CHARS[c.downcase][0].downcase if c.downcase!.nil?
  66.     return ALBHED_CHARS[c.downcase][0].upcase
  67.   end
  68.  
  69. end
  70.  
  71. class Window_Base < Window
  72.   #--------------------------------------------------------------------------
  73.   # ● 通常文字の処理
  74.   #--------------------------------------------------------------------------
  75.   alias albhed_process_normal_character process_normal_character
  76.   def process_normal_character(c, pos)
  77.     if @trans.nil?
  78.       @trans = true
  79.     end
  80.     return albhed_process_normal_character(c, pos) unless $game_switches[Albhed::ALBHED_SWITCH]
  81.     if c == "{"
  82.       @trans = false
  83.       return
  84.     end
  85.     if c == "}"
  86.       @trans = true
  87.       return
  88.     end
  89.     c = Albhed.translate(c) if @trans
  90.     change_color(text_color(Albhed::ALBHED_COLOR)) if @trans
  91.     text_width = text_size(c).width
  92.     draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
  93.     change_color(normal_color)
  94.     pos[:x] += text_width
  95.   end
  96. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement