RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Displaying character names...

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 83
Me again.. sorry I seem only to ask questions x.x  But neither of my projects is at a level where it's rolling and I feel confident there'll be anything presentable.

Anyhow, does anyone know a way to display a character's name in a little text box Above the main text box, so it's easy to show who's talking but doesn't waste a whole line of text space?

Alternately.. was there ever a script capable of displaying smaller text and text boxes at specific locations on the screen, a-la speech bubbles?

Thanks in advance!

*
Rep:
Level 102
2014 Biggest Narcissist Award2014 Biggest Forum Potato2014 Best Non-RM Creator2013 Best Game Creator (Non-RM)2013 Best IRC ChatterboxParticipant - GIAW 112012 Most Successful Troll2012 Funniest Member2012 Best Use Of Avatar and Signature space2012 Best IRC ChatterboxSecret Santa 2012 ParticipantProject of the Month winner for November 2009For being a noted contributor to the RMRK Wiki2010 Most Successful Troll2010 Biggest Forum Couch Potato2010 Best IRC Chatterbox
I got this out of an old RMXP project of mine. It's Slipknot's Advanced Message System. It can display a name box over the message box.

Just enter \na[CHARACTER NAME HERE] in your message box.

Code: [Select]
#-----------------------------------------------------------------
# ? Slipknot's Advance Message System ?
#-----------------------------------------------------------------
#  Last Update: 03/12/05
#   - Added the window over event
#   - Show Picure inside the window
#   - Added the icon display
#   - Added the item, weapon, armor & skill icon display
#   - Added the hero class name
#   - Fixed some little things
#-----------------------------------------------------------------
#  - Show Picture (above) by Slipknot
#  - Auto Resize by Slipknot
#  - Different Display Text by Slipknot
#  - Bold & Italic Text by Slipknot
#  - Hero Class Name by Slipknot
#  - Icon Display by Slipknot
#  - Item, Weapon, Armor & Skill icon by Dubealex*
#  - Show Picture (in) by Dubealex*
#  - Name Box by Dubealex*
#  - Text size by Dubealex*
#  - Text font by Dubealex*
#  - Window Over Event by Dubealex*
#  - Outline Text from Alestian Story*
#  - Shadow Text from Alestian Story*
#  * edited by Slipknot
#-----------------------------------------------------------------
# Set the default text display
$default_text = 0
#-----------------------------------------------------------------
class Window_Message < Window_Selectable
#-----------------------------------------------------------------
  def initialize
    super(65,299,510,175)
    self.contents = Bitmap.new(width-32,height-32)
    self.visible = false
    self.z = 9998
    @contents_showing = @fade_in = @fade_out = false
    @cursor_width = 0
    self.active = false
    self.index = -1
    self.opacity = 0
    # Change it to change the pictures folder for the messages
    @path = "Graphics/Pictures/Message/"
    @back = Window_Base.new(self.x,self.y,self.width,self.height)
    @back.visible = false
  end
#-----------------------------------------------------------------
  def dispose
    terminate_message
    $game_temp.message_window_showing = false
    @back.dispose
    if @input_number_window != nil
      @input_number_window.dispose
    end; super
  end
#-----------------------------------------------------------------
  alias sk_terminate_message terminate_message
  def terminate_message
    sk_terminate_message
    if @name_box != nil
     @name_box.dispose
     @name_box = nil
    end
    if @name_box_text  != nil
      @name_box_text.dispose
      @name_box_text = nil
    end
    if @picture != nil
      @picture.dispose
      @picture = nil
    end
  end
#-----------------------------------------------------------------
  def refresh
    self.contents.clear
    # Setting the text options to default
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = 22
    self.contents.font.bold = false
    self.contents.font.italic = false
    case $default_text
    when 0 then disp_text
    when 1 then disp_text(false,true)
    when 2 then disp_text(true) end
    # Setting some variables to 0
    @cursor_width = color = x = y = sx = 0
    x=8 if $game_temp.choice_start == 0
    if $game_temp.message_text != nil
      text = $game_temp.message_text
      begin
        last_text = text.clone
        # Show Variables Value
        text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
      end until text == last_text
      # Show Hero Name
      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
      end
      # Show Hero Class Name
      text.gsub!(/\\[Cc]lass\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].class_name : ""
      end
      name_box = face = picture = over_event = false
      # Name box
      if (/\\[Nn]a\[(.+?)\]/.match(text)) != nil
        name_box = true
        name_text = $1
        text.sub!(/\\[Nn]a\[(.*?)\]/){""}
      end
      # Picture
      if (/\\[Pp]ic\[(.+?)\]/.match(text)) != nil
        picture = true
        pic_name = $1
        text.sub!(/\\[Pp]ic\[(.*?)\]/){""}
      end
      # Face
      if (/\\[Ff]ace\[(.+?)\]/.match(text)) != nil
        @face = true
        face_name = $1
        text.sub!(/\\[Ff]ace\[(.*?)\]/){""}
      end
      # Window over event
      if (/\\[Pp]\[([-1,0-9]+)\]/.match(text)) != nil
        over_event = true
        event = $1.to_i
        text.sub!(/\\[Pp]\[([-1,0-9]+)\]/){""}
      end
      # "\" display
      text.gsub!(/\\\\/){"\000"}
      # Text Color
      text.gsub!(/\\[Cc]\[([0-9]+)\]/){"\001[#{$1}]"}
      # Show Gold Window
      text.gsub!(/\\[Gg]/){"\002"}
      # Text size
      text.gsub!(/\\[Tt][Ss]\[([0-9]+)\]/){"\003[#{$1}]"}
      # Text font
      text.gsub!(/\\[Ff]ont\[(.+?)\]/){"\004[#{$1}]"}
      # Text different display
      text.gsub!(/\\[Tt]ext\[([0-9]+)\]/){"\005[#{$1}]"}
      # SlipKnot's Icon
      text.gsub!(/\\[Ii]con\[(.+?)\]/){"\006[#{$1}]"}
      # Dubealex's Icon
      text.gsub!(/\\[Ii]i{([IiWwAaSs]?)}\[([0-9]+)\]/){change_icon($1,$2.to_i)}
      # Bold font
      text.gsub!(/\\[Bb]/){"\007"}
      # Italic font
      text.gsub!(/\\[Ii]/){"\010"}
      # Array with all the lines width
      stxt = [0,0,0,0]
      @back.height = 32
      icon = ""; val = 0
      x = 112 if @face
      while ((c = text.slice!(/./m)) != nil)
        if c == "\000" then c = "\\" end
        if c == "\001"
          text.sub!(/\[([0-9]+)\]/, "")
          color = $1.to_i
          self.contents.font.color = text_color(color) if color >= 0 and color <= 7
          next
        end
        if c == "\002"
          if @gold_window == nil
            @gold_window = Window_Gold.new
            @gold_window.x = 560 - @gold_window.width
            if $game_temp.in_battle then @gold_window.y = 192
            else @gold_window.y = self.y >= 128 ? 32 : 384 end
            @gold_window.opacity = @back.opacity
            @gold_window.back_opacity = @back.back_opacity
          end; next
        end
        if c == "\003"
          text.sub!(/\[([0-9]+)\]/, "")
          self.contents.font.size = [[$1.to_i,8].max,32].min
          next
        end
        if c == "\004"
          text.sub!(/\[(.+?)\]/, "")
          self.contents.font.name = $1.to_s
          next
        end
        if c == "\005"
          text.sub!(/\[([0-9]+)\]/, "")
          case $1.to_i
          when 0 then disp_text
          when 1 then disp_text(false,true)
          when 2 then disp_text(true) end
          next
        end
        if c == "\006"
          text.sub!(/\[(.+?)\]/, "")
          icon = $1.to_s
          val += 24; c = ""
        end
        if c == "\007"
          if self.contents.font.bold
            self.contents.font.bold = false
          else self.contents.font.bold = true end
          next
        end
        if c == "\010"
          if self.contents.font.italic
            self.contents.font.italic = false
          else self.contents.font.italic = true end
          next
        end
        if c == "\011"
          icon = $gold_name
          val += 24; c = ""
        end
        if c == "\013"
          text.sub!(/\[(.*?)\]/,"")
          icon = $1.to_s
          val += 24; c = ""
        end
        if c == "\n"
          @cursor_width = [@cursor_width,x].max if y >= $game_temp.choice_start
          y += 1; x = sx = 0
          sx = x = 112 if @face
          x,sx = 8,14 if y >= $game_temp.choice_start
          next
        else stxt[y] += (self.contents.text_size(c).width+val) end
        @back.height = (y*32)+64
        if icon != ""
          self.contents.blt(4+x,32*y+5,RPG::Cache.icon(icon),Rect.new(0,0,24,24))
          x += 24; val,icon = 0,""
        end
        if $outline_text and !$shadow_text
          draw_text_outline(4+x,32*y,40,32,c,color)
        elsif $shadow_text and !$outline_text
          draw_text_shadow(4+x,32*y,40,32,c,color)
        else
          self.contents.font.color = text_color(color)
          self.contents.draw_text(4+x,32*y,40,32,c)
        end
        x += self.contents.text_size(c).width
      end
      @back.width = stxt.max+42+sx
      men_pos
    end
    if $game_temp.choice_max > 0
      @item_max = $game_temp.choice_max
      self.active,self.index = true,0
    end
    if $game_temp.num_input_variable_id > 0
      digits_max = $game_temp.num_input_digits_max
      number = $game_variables[$game_temp.num_input_variable_id]
      @input_number_window = Window_InputNumber.new(digits_max)
      @input_number_window.number = number
      @back.height += 32
      width = [@back.width,(@input_number_window.width-16)].max
      @back.width = width; men_pos
    end
    if over_event
      if $game_map.events != nil
        if event <= 0 then ch = $game_player
        else ch = $game_map.events[event] end
        fx = [[ch.screen_x-@back.width/2,4].max,636-@back.width].min
        fy = [[ch.screen_y-(@back.height+48),4].max,476-@back.height].min
        self.x = @back.x = fx
        self.y = @back.y = fy
      end
    end
    if picture
      px = self.x + @back.width
      @picture = Sprite.new
      @picture.bitmap = RPG::Cache.load_bitmap(@path,pic_name)
      @picture.x = px - @picture.bitmap.width
      @picture.y = self.y - @picture.bitmap.height
    end
    if name_box
      nbx,nby = self.x,self.y-15
      w = self.contents.text_size(name_text).width+12
      @name_box = Window_Base.new(nbx,nby,w,32)
      @name_box.z = self.z+1
      nbx += 6; nby += 4
      @name_box_text  = Name_Box_Text.new(nbx,nby,name_text)
      @name_box_text.z = self.z+2
    end
    if @face
      face = RPG::Cache.load_bitmap(@path,face_name)
      @back.height <= 128 ? fy = 0 : fy = ((@back.height-128)/2)
      self.contents.blt(0,fy,face,Rect.new(0,0,96,96))
      @back.height = 128 if @back.height <= 128
      men_pos
      @face = false
    end
  end
#-----------------------------------------------------------------
  def update
    super
    if @fade_in
      self.contents_opacity += 24
      if @input_number_window != nil
        @input_number_window.contents_opacity += 24
      end
      @fade_in = false if self.contents_opacity == 255
      return
    end
    if @input_number_window != nil
      @input_number_window.update
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        $game_variables[$game_temp.num_input_variable_id] =
          @input_number_window.number
        $game_map.need_refresh = true
        @input_number_window.dispose
        @input_number_window = nil
        terminate_message
      end; return
    end
    if @contents_showing
      if Input.trigger?(Input::B)
        if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
          $game_system.se_play($data_system.cancel_se)
          $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
          terminate_message
        end
      end
      if Input.trigger?(Input::C)
        if $game_temp.choice_max > 0
          $game_system.se_play($data_system.decision_se)
          $game_temp.choice_proc.call(self.index)
        end; terminate_message
      end; return
    end
    if @fade_out == false and $game_temp.message_text != nil
      @contents_showing = true
      $game_temp.message_window_showing = true
      reset_window; refresh
      Graphics.frame_reset
      sk_visible
      self.contents_opacity = 0
      if @input_number_window != nil
        @input_number_window.contents_opacity = 0
      end
      @fade_in = true; return
    end
    if self.visible
      @fade_out = true
      @back.opacity -= 48
      if @back.opacity == 0
        sk_visible(false)
        @fade_out = false
        $game_temp.message_window_showing = false
      end; return
    end
  end
#-----------------------------------------------------------------
  def change_icon(option,index)
    option == nil ? option = "" : nil
    option.downcase!
    case option
    when "i" then s = $data_items[index]
    when "w" then s = $data_weapons[index]
    when "a" then s = $data_armors[index]
    when "s" then s = $data_skills[index] end
    return sprintf("\013[%s]%s",s.icon_name,s.name) unless s.name == nil
  end
#-----------------------------------------------------------------
  def disp_text(w1=false,w2=false)
    $outline_text,$shadow_text = w1,w2
  end
#-----------------------------------------------------------------
  def sk_visible(s=true)
    self.visible,@back.visible = s,s
  end
#-----------------------------------------------------------------
  def men_pos
    if $game_temp.in_battle then self.y = 96 - @back.height/2
    else
      case $game_system.message_position
      when 0 then self.y = 96 - @back.height/2
      when 1 then self.y = 240 - @back.height/2
      when 2 then self.y = 384 - @back.height/2 end
    end
    self.x = 320 - @back.width/2
    if @input_number_window != nil
      @input_number_window.y = (self.y+$game_temp.num_input_start*32)
      @input_number_window.x = self.x+8
      @input_number_window.x = self.x+8+112 if @face
    end
    @back.x,@back.y = self.x,self.y
  end
#-----------------------------------------------------------------
  def reset_window
    men_pos
    if $game_system.message_frame == 0 then @back.opacity = 255
    else @back.opacity = 0 end
    @back.back_opacity = 160
  end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Name_Box_Text < Window_Base
#-----------------------------------------------------------------
  def initialize(x,y,text)
    super(x-16,y-16,text.size*12+32,56)
    init; self.opacity = 0
    w,h = self.contents.width,self.contents.height
    if $outline_text and !$shadow_text then draw_text_outline(0,0,w,h,text)
    elsif $shadow_text and !$outline_text then draw_text_shadow(0,0,w,h,text)
    else self.contents.draw_text(0,0,w,h,text) end
  end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Window_Base < Window
#-----------------------------------------------------------------
  def draw_text_outline(x,y,wid,hei,str,col=0,ali=0)
    self.contents.font.color = Color.new(0,0,0,255)
    self.contents.draw_text(x+1,y,wid,hei,str,ali)
    self.contents.draw_text(x-1,y,wid,hei,str,ali)
    self.contents.draw_text(x,y+1,wid,hei,str,ali)
    self.contents.draw_text(x,y-1,wid,hei,str,ali)
    self.contents.font.color = text_color(col)
    self.contents.draw_text(x,y,wid,hei,str,ali)
  end
#-----------------------------------------------------------------
  def draw_text_shadow(x,y,wid,hei,str,col=0,ali=0)
    self.contents.font.color = Color.new(0,0,0,192)
    self.contents.draw_text(x+1,y+1,wid,hei,str,ali)
    self.contents.font.color = Color.new(0,0,0,96)
    self.contents.draw_text(x+2,y+2,wid,hei,str,ali)
    self.contents.font.color = text_color(col)
    self.contents.draw_text(x,y,wid,hei,str,ali)
  end
#-----------------------------------------------------------------
  def init(win=self,type=0,size=0,wid=0,hei=0)
    swid = (wid == 0 ? win.width-32 : wid)
    shei = (hei == 0 ? win.height-32 : hei)
    win.contents = Bitmap.new(swid,shei)
    type = $defaultfonttype if type == 0
    size = $defaultfontsize if size == 0
    win.contents.font.name = type
    win.contents.font.size = size
  end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------

*
Rep:
Level 87
Ccoa's Universal Messaging System allows you to do this also.  Sorry I don't have a link, but you should be able to google it without too much trouble.

There are likely several other message systems that will do this too.
Always remember you're unique.
Just like everybody else.

**
Rep:
Level 83
Ah, thank you both o.o 

I'll pursue them both.. thanks for the swift answer! ^^

****
kikiki
Rep:
Level 84
Hi
Hi

**
Rep:
Level 83
Thanks again o.o

Unfortunately it would seem the demo for Slipknot's system crashes with the error 'RGSS Player has stopped working' whenever I run it, and Ccoa's.. doesn't seem to be anything besides an empty game in terms of the demo proper and has no manual as such.

I guess they both assume a certain level of expertise beyond merely inserting the things.. or rather, experience employing scripts in the past.  Hu..

*sets about trying to muddle through*
« Last Edit: October 30, 2009, 10:18:54 PM by Fensfield »

*
Rep:
Level 87
for ccoa's, you paste the scripts just above Main, and format your text box as follows:

\nm[Harold]What are you doing in here?


This will show a text box with "What are you doing in here?", with a smaller box above displaying Harold's name.
Always remember you're unique.
Just like everybody else.

**
Rep:
Level 83
Thanks again ^^

**
Rep:
Level 83
Sorry, I'm still having problems x.x

Specifically, the names are appearing above the window alright, but without a box, so they look rather messy.

Is this normal behaviour or.. am I maybe missing a resource (I couldn't find anything ferreting about in the demo project's resources)?  The name insertion I'm using is actually called as \nm[\N[1]], since the game asks the player to name the protagonist - but that doesn't seem to be the problem, since a directly entered name also lacks a box surrounding it and the chosen name shows up just the same.

There doesn't seem to be anything that'd clearly fix the problem in the list of commands at the top of the UMS script either.

EDIT: Found the problem!  Whether or not the name window should be displayed, or just the text, was an option buried in the code and needed to be set manually to 'true'

Still I wish I could find why it isn't responding to colour hex commands... ( \c[#999999] in this case ).  Instead of changing the text colour as the flag description in the script says it ought, it just prints \c[#999999] as part of the message.
« Last Edit: November 03, 2009, 04:03:04 PM by Fensfield »

*
Rep:
Level 87
I haven't tried it, but a quick glance at the script indicates you need to format hex as \c[0x999999], not as \c[#999999].
Always remember you're unique.
Just like everybody else.

**
Rep:
Level 83
Ah there we go.  Thanks again for all the help!