Show text in a special way

Discussion in 'RGSS3 Script Requests' started by Udlice, May 31, 2015.

  1. Udlice

    Udlice Veteran Veteran

    Messages:
    54
    Likes Received:
    11
    First Language:
    French
    Hi,

    First, thanks for taking the time to read this.

    I would like to be able to show text in the "background" of my maps. A good example of what I want to do is the game Nihilumbra.

    Nihilumbra.png

    This is a screenshot of Nihilumbra..

    There is two big differences between this way to show text and how RPG maker do it :

    -There is no "wait" that stop the player from moving while the text is displayed.

    -And the text stick to the background (like events or tiles do) and not to the screen (like normal text in RPG maker and pictures do).

    This is the effect I want to have. Is there a script out there that can do this ?
     
    #1
  2. Trihan

    Trihan Speedy Scripter Veteran

    Messages:
    1,483
    Likes Received:
    974
    Location:
    Buckie, Scotland
    First Language:
    English
    As long as you create a bitmap object that covers the whole screen, you can use the draw_text method to draw text anywhere you like.
     
    #2
  3. Yuuta Kirishima

    Yuuta Kirishima Software Engineer/Professional Mayonnaise Player Veteran

    Messages:
    549
    Likes Received:
    131
    Location:
    North Carolina
    First Language:
    Engilsh
    Primarily Uses:
    RMMV
    You could transform the text into images and use an overlay script.
     
    #3
    Genocidal Dave likes this.
  4. Udlice

    Udlice Veteran Veteran

    Messages:
    54
    Likes Received:
    11
    First Language:
    French
    Thanks for the quick reply.

    I know it is possible to do this with pictures but there are Two problems :

    -It requires A LOT of pictures if I want to show text this way often in the game.

    -If I want to correct something, to change the text, or to translate the whole game, I need to change the pictures themselves and it's a hudge pain.

    That's why I asked for a script.

    But thanks for the help.
     
    Last edited by a moderator: May 31, 2015
    #4
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    I've moved this thread to RGSS3 Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.
     
    #5
  6. Ossra

    Ossra Formerly Exhydra Veteran

    Messages:
    646
    Likes Received:
    491
    First Language:
    English
    Primarily Uses:
    RMMV
    Hmm, well, I do have a script you might be interested in. I really have not spent too much time on it, so it is un-optimized and possibly a bit wonky. But, it will certainly do what you are wanting.

    Code:
    #==============================================================================# ** Cache#------------------------------------------------------------------------------#  This module loads graphics, creates bitmap objects, and retains them.# To speed up load times and conserve memory, this module holds the# created bitmap object in the internal hash, allowing the program to# return preexisting objects when the same bitmap is requested again.#==============================================================================module Cache    #--------------------------------------------------------------------------  # * ALIAS - Load Bitmap  #--------------------------------------------------------------------------  unless method_defined?(:bit_text_6Lg5dvTN_cache_load_bitmap)    class << self  	  alias :bit_text_6Lg5dvTN_cache_load_bitmap :load_bitmap    end  end    def self.load_bitmap(folder_name, filename, hue = 0, *args, &block)        if filename.is_a?(Hash)      @cache ||= {}      text_bitmap(filename)    else      bit_text_6Lg5dvTN_cache_load_bitmap(folder_name, filename, hue = 0, *args, &block)    end  end    #--------------------------------------------------------------------------  # * NEW - Create/Get Text Bitmap  #--------------------------------------------------------------------------  def self.text_bitmap(data)      unless include?(data[:name])      font = Font.new            data[:font].each_pair { |key, value|         if font.respond_to?("#{key}=")          font.send("#{key}=", value)        end      }            f_bitmap      = Bitmap.new(1,1)      f_bitmap.font = font      f_rect        = f_bitmap.text_size(data[:text])            bitmap        = Bitmap.new(f_rect.width, f_rect.height + (f_rect.height / 2))      bitmap.font   = font            bitmap.draw_text(0, 0, f_rect.width, f_rect.height + (f_rect.height / 2), data[:text], 1)      @cache[data[:name]] = bitmap unless include?(data[:name])      return @cache[data[:name]]    else      return @cache[data[:name]]    end      end  end # Cache
    To call the script, use the following in either a 'script' event command or elsewhere.
    Code:
    #           :name, <font_name>, :size, <font_size>, :color, <font_color>,#           :bold, <boolean>, :outline, <boolean>, out_color, <outline_color>  font = Hash[:name, "Verdana", :size, 28, :color, Color.new(148,148,148,150),            :bold, true, :outline, true, :out_color, Color.new(64,64,64,150)]#           :name, <picture_name>, :text, <picture_text>, :font, <font_hash>data = Hash[:name, "TextImage", :text, "Blah Blah Blah!", :font, font ]#                    [picID] data_hash, origin, x, y, zoom_x, zoom_y, opacity, blend_type$game_map.screen.pictures[2].show(data, 0, 393, 122, 100.0, 100.0, 255, 0) 
    In the above example, a new picture with an ID of 2 is created with the image data being text. You can then move the picture around, fade it out, and so on. You can use this in conjunction with Modern Algebra's 'Fix Picture to Map', or other similar scripts to pin the image in place and/or change its z-value.
     
    #6
  7. Udlice

    Udlice Veteran Veteran

    Messages:
    54
    Likes Received:
    11
    First Language:
    French
    Look perfect to me.

    Thanks a lot @Hexhydra !!

     
     
    #7
  8. tv.ghost

    tv.ghost Veteran Veteran

    Messages:
    284
    Likes Received:
    85
    First Language:
    English
    Primarily Uses:
    RMVXA
    Fixed code. (Untested)
    Code:
    #==============================================================================
    # ** Bitmap text
    # Author: Ossra (formerly Exhydra)
    # Site: https://forums.rpgmakerweb.com/index.php?members/ossra.19410/
    # Original link: https://forums.rpgmakerweb.com/index.php?threads/show-text-in-a-special-way.40599/
    #==============================================================================
    # data = Hash[:name, "TextImage", :text, "Blah Blah Blah!", :font, font ]
    # [picID] data_hash, origin, x, y, zoom_x, zoom_y, opacity, blend_type
    # $game_map.screen.pictures[2].show(data, 0, 393, 122, 100.0, 100.0, 255, 0)
    #==============================================================================
    module Cache  
    #--------------------------------------------------------------------------
     # * ALIAS - Load Bitmap
     #--------------------------------------------------------------------------
     unless method_defined?(:bit_text_6Lg5dvTN_cache_load_bitmap)  
       class << self      
         alias :bit_text_6Lg5dvTN_cache_load_bitmap :load_bitmap
       end
     end  
     def self.load_bitmap(folder_name, filename, hue = 0, *args, &block)      
       if filename.is_a?(Hash)    
         @cache ||= {}    
         text_bitmap(filename)  
       else    
         bit_text_6Lg5dvTN_cache_load_bitmap(folder_name, filename, hue = 0, *args, &block)  
       end
     end
     #--------------------------------------------------------------------------
     # * NEW - Create/Get Text Bitmap
     #--------------------------------------------------------------------------
     def self.text_bitmap(data)  
       unless include?(data[:name])  
         font = Font.new      
         data[:font].each_pair { |key, value|    
         if font.respond_to?("#{key}=")    
           font.send("#{key}=", value)    
         end    
         }    
         f_bitmap      = Bitmap.new(1,1)  
         f_bitmap.font = font
         f_rect        = f_bitmap.text_size(data[:text])  
         bitmap        = Bitmap.new(f_rect.width, f_rect.height + (f_rect.height / 2))
         bitmap.font   = font
         bitmap.draw_text(0, 0, f_rect.width, f_rect.height + (f_rect.height / 2), data[:text], 1)  
         @cache[data[:name]] = bitmap unless include?(data[:name])    
         return @cache[data[:name]]
       else  
         return @cache[data[:name]]  
       end    
     end
     end # Cache
     
    #8

Share This Page