Advertisement
Dekita

reverse text

Aug 19th, 2014
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. #===============================================================================
  2. # Author : Dekita
  3. # Written for q8fft3
  4. # Date : 16-o8-2014.
  5. #===============================================================================
  6. module Text_Mods
  7. #===============================================================================
  8. #-----------------------------------------------------------------------------
  9. # :type => switch ID to enable.
  10. #-----------------------------------------------------------------------------
  11. Switches={
  12. :reverse_words => 1,
  13. :reverse_letters => 2,
  14. :reverse_both => 3,
  15. }
  16. #-----------------------------------------------------------------------------
  17. #
  18. #-----------------------------------------------------------------------------
  19. end
  20. #===============================================================================
  21. class Game_Message
  22. #===============================================================================
  23. #-----------------------------------------------------------------------------
  24. # Rewrite
  25. #-----------------------------------------------------------------------------
  26. def all_text
  27. can_mod = can_mod_texts?.clone
  28. old_text = @texts.inject("") { |result, text| result += text }
  29. text = old_text
  30. if can_mod.shift
  31. text = old_text.split(//u).reverse.join.split(/ /).map do |w|
  32. w.split(//u).reverse.join
  33. end.join(' ')
  34. end
  35. if can_mod.shift
  36. ot = old_text.split(//u).reverse!.join.split(//u)
  37. text = ot.reverse.join.split(/ /).map do |w|
  38. w.split(//u).reverse.join
  39. end.join(' ')
  40. end
  41. if can_mod.shift
  42. text = old_text.split(//u).reverse!.join
  43. end
  44. return "#{text}\n"
  45. end
  46. #-----------------------------------------------------------------------------
  47. # New Method
  48. #-----------------------------------------------------------------------------
  49. def can_mod_texts?
  50. [:reverse_words,:reverse_letters,:reverse_both].inject([]) do |res,sym|
  51. res << $game_switches[Text_Mods::Switches[sym]]
  52. end.compact
  53. end
  54. #-----------------------------------------------------------------------------
  55. #
  56. #-----------------------------------------------------------------------------
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement