IceDragon200

[IEI]Game_Strings

Jun 23rd, 2012
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.16 KB | None | 0 0
  1. =begin
  2.  ♥ IEI - Game_Strings
  3.  ──────────────────────────────────────────────────────────────────────────────
  4.  • Created By    : IceDragon
  5.  • Data Created  : 23/06/2012
  6.  • Data Modified : 23/06/2012
  7.  • Version       : 1.0
  8.  ─┐ ● Introduction ┌───────────────────────────────────────────────────────────
  9.   └────────────────┘
  10.   Nothing big, just a class similar to Game_Variables,
  11.   only difference it holds strings
  12.  ─┐ ● How To Use ┌─────────────────────────────────────────────────────────────
  13.   └──────────────┘
  14.   $game_strings[id] = "string"
  15.  ──────────────────────────────────────────────────────────────────────────────
  16. =end
  17. ($imported||={})['IEI::Game_Strings'] = 0x10000
  18. # ╒╕ ■                                                          DataManager ╒╕
  19. # └┴────────────────────────────────────────────────────────────────────────┴┘
  20. class << DataManager
  21.   # // Create the Game_Strings object on new games
  22.   alias :gms_crt_gm_objs :create_game_objects
  23.   def create_game_objects
  24.     gms_crt_gm_objs
  25.     $game_strings = Game_Strings.new
  26.   end
  27.   # // Save the Game_Strings, or create a new one if it doesn't exist
  28.   alias :gms_mk_sv_cont :make_save_contents
  29.   def make_save_contents
  30.     contents = gms_mk_sv_cont
  31.     contents[:strings] = $game_strings||Game_Strings.new
  32.     contents
  33.   end
  34.   # // Pull the Game_Strings or create a new one if it doesn't exist
  35.   alias :gms_ex_sv_cont :make_save_contents
  36.   def extract_save_contents contents
  37.     gms_ex_sv_cont contents
  38.     $game_strings = contents[:strings]||Game_Strings.new
  39.   end
  40. end
  41. # ╒╕ ♥                                                         Game_Strings ╒╕
  42. # └┴────────────────────────────────────────────────────────────────────────┴┘
  43. class Game_Strings
  44.   def initialize
  45.     @data = Array.new
  46.   end
  47.   def [] id
  48.     @data[id] || ""
  49.   end
  50.   def []= id,v
  51.     @data[id] = v
  52.   end
  53.   include IEI::Tracker if $imported['IEI::Tracker']
  54. end
  55. # ┌┬────────────────────────────────────────────────────────────────────────┬┐
  56. # ╘╛ ● End of File ●                                                        ╘╛
Advertisement
Add Comment
Please, Sign In to add comment