The best script request ever! Message System addon

Okay, so what I'm after should HOPEFULLY be easy enough to implement. It's been done before but I want something... simpler.

Basically, what I want is a box, above the message box, which is the same length, and will have a defined name in it (Not an event or player, but something I can use myself). As well as this, I'd like a way to allign the name to the left, center, or right.

Here's a picture so you know what I mean:

Image


I was thinking something along the lines of typing \n[Jason] to show the name Jason in the box, and maybe \a[1] or \a[left] to align it to the left, or [2]/[center] for the center, and likewise for the right. If you could get it as close (And easy to use) as this that'd be great! although I don't mind if the alligning would be too awkward or whatever, just as long as I can get the seperate box with a name in it (But the box only appears if \n[Text stuff] is in the message, otherwise it'll look weird)

The reason I'm not using an already made CMS/UMS for this is because they always add unnecessary features and the coding is so awkward to just edit the bits I need...

By the way if you need more info, just ask!
Aww no replies after 2 days, you guys make me sad :sad: <-- See, sad!
here you go.
note it over-writes some methods.
instructions inside the script.
  1. #==============================================================================
  2. #   Message Name Box
  3. #-----------------------------------------------------------------------------
  4. # made by: Silverwind on HBGames.org
  5. # version: 1.0
  6. #
  7. # How to use:
  8. #  1. add "\N[name]" in the begining of a 'show text' command.
  9. #    for example: \N[Alex]Hi, my name is Alex!
  10. #  2. set the align of the name by a call script saying:
  11. #     $game_temp.name_box_align = 0, 1, or 2
  12. #     where (0..flush left, 1..center, 2..flush right)
  13. #
  14. # edits the following classes
  15. #  * Scene_map
  16. #    create, update and dispose the name-box window.
  17. #    re-writes the methods: initialize, update
  18. #    see lines: 44, 66, 105
  19. #    
  20. #  * Window_Message
  21. #    do not display the name when /N[i] is used
  22. #    re-writes the methods: refresh
  23. #    see lines: 217-224
  24. #
  25. # new classes:
  26. #  * Window_Name_Box
  27. #==============================================================================
  28.  
  29. #==============================================================================
  30. # ** Scene_Map
  31. #------------------------------------------------------------------------------
  32. #  This class performs map screen processing.
  33. #==============================================================================
  34.  
  35. class Scene_Map
  36.   #--------------------------------------------------------------------------
  37.   # * Main Processing
  38.   #--------------------------------------------------------------------------
  39.   def main
  40.     # Make sprite set
  41.     @spriteset = Spriteset_Map.new
  42.     # Make message window
  43.     @message_window = Window_Message.new
  44.     @message_name_window = Window_Name_Box.new
  45.     # Transition run
  46.     Graphics.transition
  47.     # Main loop
  48.     loop do
  49.       # Update game screen
  50.       Graphics.update
  51.       # Update input information
  52.       Input.update
  53.       # Frame update
  54.       update
  55.       # Abort loop if screen is changed
  56.       if $scene != self
  57.         break
  58.       end
  59.     end
  60.     # Prepare for transition
  61.     Graphics.freeze
  62.     # Dispose of sprite set
  63.     @spriteset.dispose
  64.     # Dispose of message window
  65.     @message_window.dispose
  66.     @message_name_window.dispose
  67.     # If switching to title screen
  68.     if $scene.is_a?(Scene_Title)
  69.       # Fade out screen
  70.       Graphics.transition
  71.       Graphics.freeze
  72.     end
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # * Frame Update
  76.   #--------------------------------------------------------------------------
  77.   def update
  78.     # Loop
  79.     loop do
  80.       # Update map, interpreter, and player order
  81.       # (this update order is important for when conditions are fulfilled
  82.       # to run any event, and the player isn't provided the opportunity to
  83.       # move in an instant)
  84.       $game_map.update
  85.       $game_system.map_interpreter.update
  86.       $game_player.update
  87.       # Update system (timer), screen
  88.       $game_system.update
  89.       $game_screen.update
  90.       # Abort loop if player isn't place moving
  91.       unless $game_temp.player_transferring
  92.         break
  93.       end
  94.       # Run place move
  95.       transfer_player
  96.       # Abort loop if transition processing
  97.       if $game_temp.transition_processing
  98.         break
  99.       end
  100.     end
  101.     # Update sprite set
  102.     @spriteset.update
  103.     # Update message window
  104.     @message_window.update
  105.     @message_name_window.update
  106.     # If game over
  107.     if $game_temp.gameover
  108.       # Switch to game over screen
  109.       $scene = Scene_Gameover.new
  110.       return
  111.     end
  112.     # If returning to title screen
  113.     if $game_temp.to_title
  114.       # Change to title screen
  115.       $scene = Scene_Title.new
  116.       return
  117.     end
  118.     # If transition processing
  119.     if $game_temp.transition_processing
  120.       # Clear transition processing flag
  121.       $game_temp.transition_processing = false
  122.       # Execute transition
  123.       if $game_temp.transition_name == ""
  124.         Graphics.transition(20)
  125.       else
  126.         Graphics.transition(40, "Graphics/Transitions/" +
  127.           $game_temp.transition_name)
  128.       end
  129.     end
  130.     # If showing message window
  131.     if $game_temp.message_window_showing
  132.       return
  133.     end
  134.     # If encounter list isn't empty, and encounter count is 0
  135.     if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  136.       # If event is running or encounter is not forbidden
  137.       unless $game_system.map_interpreter.running? or
  138.              $game_system.encounter_disabled
  139.         # Confirm troop
  140.         n = rand($game_map.encounter_list.size)
  141.         troop_id = $game_map.encounter_list[n]
  142.         # If troop is valid
  143.         if $data_troops[troop_id] != nil
  144.           # Set battle calling flag
  145.           $game_temp.battle_calling = true
  146.           $game_temp.battle_troop_id = troop_id
  147.           $game_temp.battle_can_escape = true
  148.           $game_temp.battle_can_lose = false
  149.           $game_temp.battle_proc = nil
  150.         end
  151.       end
  152.     end
  153.     # If B button was pressed
  154.     if Input.trigger?(Input::B)
  155.       # If event is running, or menu is not forbidden
  156.       unless $game_system.map_interpreter.running? or
  157.              $game_system.menu_disabled
  158.         # Set menu calling flag or beep flag
  159.         $game_temp.menu_calling = true
  160.         $game_temp.menu_beep = true
  161.       end
  162.     end
  163.     # If debug mode is ON and F9 key was pressed
  164.     if $DEBUG and Input.press?(Input::F9)
  165.       # Set debug calling flag
  166.       $game_temp.debug_calling = true
  167.     end
  168.     # If player is not moving
  169.     unless $game_player.moving?
  170.       # Run calling of each screen
  171.       if $game_temp.battle_calling
  172.         call_battle
  173.       elsif $game_temp.shop_calling
  174.         call_shop
  175.       elsif $game_temp.name_calling
  176.         call_name
  177.       elsif $game_temp.menu_calling
  178.         call_menu
  179.       elsif $game_temp.save_calling
  180.         call_save
  181.       elsif $game_temp.debug_calling
  182.         call_debug
  183.       end
  184.     end
  185.   end
  186.  
  187. end
  188.  
  189. #==============================================================================
  190. # ** Window_Message
  191. #------------------------------------------------------------------------------
  192. #  This message window is used to display text.
  193. #==============================================================================
  194.  
  195. class Window_Message < Window_Selectable
  196.  
  197.   #--------------------------------------------------------------------------
  198.   # * Refresh
  199.   #--------------------------------------------------------------------------
  200.   def refresh
  201.     self.contents.clear
  202.     self.contents.font.color = normal_color
  203.     x = y = 0
  204.     @cursor_width = 0
  205.     # Indent if choice
  206.     if $game_temp.choice_start == 0
  207.       x = 8
  208.     end
  209.     # If waiting for a message to be displayed
  210.     if $game_temp.message_text != nil
  211.       text = $game_temp.message_text
  212.       # Control text processing
  213.       begin
  214.         last_text = text.clone
  215.         text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  216.       end until text == last_text
  217.       #---------------------------------------------------------------------
  218.       # my edit: calculate name from \N[?], replace it with blank space.
  219.       text.gsub!(/\\[Nn]\[(.*?)\]/) do
  220.         name = $1.to_s
  221.         $game_temp.message_name_box = name
  222.         ""
  223.       end
  224.       #----------------------------------------------------------------------
  225.       # Change "\\\\" to "\000" for convenience
  226.       text.gsub!(/\\\\/) { "\000" }
  227.       # Change "\\C" to "\001" and "\\G" to "\002"
  228.       text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  229.       text.gsub!(/\\[Gg]/) { "\002" }
  230.       # Get 1 text character in c (loop until unable to get text)
  231.       while ((c = text.slice!(/./m)) != nil)
  232.         # If \\
  233.         if c == "\000"
  234.           # Return to original text
  235.           c = "\\"
  236.         end
  237.         # If \C[n]
  238.         if c == "\001"
  239.           # Change text color
  240.           text.sub!(/\[([0-9]+)\]/, "")
  241.           color = $1.to_i
  242.           if color >= 0 and color <= 7
  243.             self.contents.font.color = text_color(color)
  244.           end
  245.           # go to next text
  246.           next
  247.         end
  248.         # If \G
  249.         if c == "\002"
  250.           # Make gold window
  251.           if @gold_window == nil
  252.             @gold_window = Window_Gold.new
  253.             @gold_window.x = 560 - @gold_window.width
  254.             if $game_temp.in_battle
  255.               @gold_window.y = 192
  256.             else
  257.               @gold_window.y = self.y >= 128 ? 32 : 384
  258.             end
  259.             @gold_window.opacity = self.opacity
  260.             @gold_window.back_opacity = self.back_opacity
  261.           end
  262.           # go to next text
  263.           next
  264.         end
  265.         # If new line text
  266.         if c == "\n"
  267.           # Update cursor width if choice
  268.           if y >= $game_temp.choice_start
  269.             @cursor_width = [@cursor_width, x].max
  270.           end
  271.           # Add 1 to y
  272.           y += 1
  273.           x = 0
  274.           # Indent if choice
  275.           if y >= $game_temp.choice_start
  276.             x = 8
  277.           end
  278.           # go to next text
  279.           next
  280.         end
  281.         # Draw text
  282.         self.contents.draw_text(4 + x, 32 * y, 40, 32, c)
  283.         # Add x to drawn text width
  284.         x += self.contents.text_size(c).width
  285.       end
  286.     end
  287.     # If choice
  288.     if $game_temp.choice_max > 0
  289.       @item_max = $game_temp.choice_max
  290.       self.active = true
  291.       self.index = 0
  292.     end
  293.     # If number input
  294.     if $game_temp.num_input_variable_id > 0
  295.       digits_max = $game_temp.num_input_digits_max
  296.       number = $game_variables[$game_temp.num_input_variable_id]
  297.       @input_number_window = Window_InputNumber.new(digits_max)
  298.       @input_number_window.number = number
  299.       @input_number_window.x = self.x + 8
  300.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  301.     end
  302.   end
  303.  
  304. end
  305.  
  306. class Game_Temp
  307.   attr_accessor :message_name_box   # name for message
  308.   attr_accessor :name_box_align     # name box align
  309. end
  310.  
  311. class Window_Name_Box < Window_Selectable
  312.  
  313.   def initialize
  314.     #super(80, 304, 480, 160)
  315.     super(80, 236, 480, 72)
  316.     self.contents = Bitmap.new(width - 32, height - 32)
  317.     self.visible = false
  318.     self.z = 9998
  319.     @fade_in = false
  320.     @fade_out = false
  321.     @contents_showing = false
  322.     @cursor_width = 0
  323.     self.active = false
  324.     self.index = -1
  325.     # center the name by default
  326.     @align = 1
  327.   end
  328.  
  329.   def terminate_message
  330.     self.visible = false
  331.     self.active = false
  332.     self.pause = false
  333.     self.index = -1
  334.     self.contents.clear
  335.     # Clear showing flag
  336.     @contents_showing = false
  337.     # Call message callback
  338.     if $game_temp.message_proc != nil
  339.       $game_temp.message_proc.call
  340.     end
  341.   end
  342.  
  343.   def refresh
  344.     self.contents.clear
  345.     if $game_temp.message_name_box != nil
  346.       @name = $game_temp.message_name_box
  347.       $game_temp.message_name_box = nil
  348.       if $game_temp.name_box_align != nil
  349.         @align = $game_temp.name_box_align
  350.       end
  351.     end
  352.     if @name != nil
  353.       self.visible = true
  354.       x = y = 0
  355.       w = 400
  356.       h = 32
  357.       self.contents.draw_text(4 + x, 32 * y, w, h, @name, @align)
  358.     end
  359.   end
  360.  
  361.   def update
  362.     super
  363.     if $game_temp.message_name_box != nil or @name != nil
  364.       refresh
  365.     end
  366.     if (@name != nil) and not $game_temp.message_window_showing
  367.       terminate_message
  368.       @name = nil
  369.     end
  370.   end
  371.  
  372.   def dispose
  373.     terminate_message
  374.     super
  375.   end
  376.  
  377. end
  378.  
Expand to see the code.
Oh wow that's brilliant silver! :heart:

I've just lowered the opacity to match with the current message window, and made it thinner, and it's perfect now! 😀
always glad to help :)

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=76581