Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Ugly extra space with Ucoders Message System

Ive been using Ucoders Message system for a few days now. It has been very easy to use so far. But one thing that has been peeving me about it is that there is a lot of extra space in the messages as a result of the in-text code used for text effects. Here's a picture as an example.

http://img235.imageshack.us/img235/6558/prbleemiw1.jpg[/img]
I was wondering if there might be a way to have the message system not just not display the code when writing out the message, but to act as if it wasn't even there when drawing the message boxes.

If that's not possible, could someone recommend a better message system? Other than UMS, because I tried that one and for some reason the "show choices" option is all screwy.

Here are the three parts of the script.
Code:
#===============================================================================
# ** Module UCoders - Contains Methods used by Unknown Coders' scripts
#
#    Visit Us:
#    www.unknowncoders.com
#
#-------------------------------------------------------------------------------
# Authors   Mr.Mo "Muhammet Sivri" | Trebor777
# Version   1.3 (01/12/08)
# Date      11/24/07 (m/d/y)
#===============================================================================
module UCoders
  #--------------------------------------------------------------------------
  # * Constants
  #--------------------------------------------------------------------------
  Object = {}
  Scripts = {}
  #--------------------------------------------------------------------------
  # * Include Script
  #--------------------------------------------------------------------------
  def UCoders.include(name,args) 
    Scripts[name] = args
  end
  #--------------------------------------------------------------------------
  # * Include Script
  #--------------------------------------------------------------------------
  def UCoders.has?(name)
    return !Scripts[name].nil?
  end
  #--------------------------------------------------------------------------
  # * Returns a list of parameters from an event's comments
  #--------------------------------------------------------------------------
  def UCoders.event_comment_input(*args)
    parameters = []; list = *args[0].list; lines = *args[1]; trigger = *args[2]
    return nil if list.nil? || !list.is_a?(Array)
    list.each { |o|
      next if o.code != 108 || !(o.parameters[0].to_s).include?(trigger)
      start = list.index(o)
      finish = start + lines
      for id in start...finish
        next if !list[id];  parameters.push(list[id].parameters[0])
      end
      return parameters 
    }
    return nil
  end
  #--------------------------------------------------------------------------
  # * Returns the event comment with the needed key
  #--------------------------------------------------------------------------
  def UCoders.event_comment(*args)
    parameters = []; list = *args[0].list; trigger = *args[1]
    return nil if list.nil? || !list.is_a?(Array)
    list.each { |o|  next if o.code != 108 || !(o.parameters[0].to_s).include?(trigger)
      parameters.push(o.parameters)
    }
    return parameters unless parameters.empty?
    return nil
  end
  #--------------------------------------------------------------------------
  # * Log Error - Records and Saves all errors.
  #--------------------------------------------------------------------------
  def UCoders.log_error
    # Record Error 
    k = 0
    time = Time.now.strftime("%a %d %b %Y, %X")
    log = File.open("ErrorLog.rxdata","a+")
    log.write("[ #{time} ]\n")
    # Write Message and Type
    log.write("'#{$!.message}' Type #{$!.class}\n")
    for i in 0..$!.backtrace.size
      e = $!.backtrace[i]
      /Section(.*):(.*):in (.*)/.match(e)
      space = " "*(i*2)
      log.write(space+"  <>Script '#{$RGSS_SCRIPTS[$1.to_i][1]}' | Line #{$2} | Method #{$3}\n")
      # Don't list more then 4 backtraces to make it simpler, can be changed! 
      break if i >= 4
      next if k == 1
      # Get the first trace
      script = "#{$RGSS_SCRIPTS[$1.to_i][1]}"
      line = $2
      method = $3
      k = 1
    end
    log.write("\n")
    log.close
    # Make some sense
    if $DEBUG
      print "#{$!.message} \nScript '#{script}' \nLine '#{line}' \nMethod '#{method}' \nType '#{$!.class}'"
    else
      print "Unexpected Error! The ErrorLog is in folder:\n #{File.expand_path('.')}"
    end
  end
  #--------------------------------------------------------------------------
  # * Checks the object range
  #--------------------------------------------------------------------------
  def UCoders.in_screen?(object)
    scene_x = $game_map.display_x - 256
    scene_y = $game_map.display_y - 256
    scene_width = $game_map.display_x + 2816
    scene_height = $game_map.display_y + 2176
    return (object.real_x.between?(scene_x, scene_width) and object.real_y.between?(scene_y,scene_height))
  end
  #--------------------------------------------------------------------------
  # * Get Events In (range of element)
  #--------------------------------------------------------------------------
  def UCoders.get_events_in(range,element)
    objects = []
    $game_map.events.each_value { |e| objects.push(e) if UCoders.in_range?(element, e, range) }
    return objects
  end
  #--------------------------------------------------------------------------
  # * Get Range(Element, Object)
  #--------------------------------------------------------------------------
  def UCoders.get_range(element, object)
    x = (element.x - object.x)**2
    y = (element.y - object.y)**2
    r = x + y
    return Math.sqrt(r).to_i
  end
  #--------------------------------------------------------------------------
  # * In Range?(Element, Object, Range)
  #--------------------------------------------------------------------------
  def UCoders.in_range?(element, object, range)
    x = (element.x - object.x)**2
    y = (element.y - object.y)**2
    return x + y <= (range * range)
  end
  #--------------------------------------------------------------------------
  # * In Direction?(Element, Object)
  #--------------------------------------------------------------------------
  def UCoders.in_direction?(event,object)
    return true if event.direction == 2 && object.y >= event.y && object.x == event.x
    return true if event.direction == 4 && object.x <= event.x && object.y == event.y
    return true if event.direction == 6 && object.x >= event.x && object.y == event.y
    return true if event.direction == 8 && object.y <= event.y && object.x == event.x
    return false
  end
  #--------------------------------------------------------------------------
  # * In Line?(Element, Object)
  #--------------------------------------------------------------------------
  def UCoders.in_line?(event,object)
    return (((object.y <= event.y || object.y >= event.y) && object.x == event.x) || ((object.x >= event.x || object.x <= event.x) && object.y == event.y))
  end
end
#==============================================================================
# ** Multi-Dimensional Array
#    Creates a MultiD array. When value not specified, returns nil. 
#==============================================================================
class MultiArray
  #--------------------------------------------------------------------------
  # * Initialize
  #   d : number of dimensions(x,y,z) 
  #--------------------------------------------------------------------------
   def initialize(*dimensions)
      @dimensions=Array.new(dimensions.size)
      @factors=Array.new(dimensions.size)
      product=1
      i=dimensions.size-1
      while i >= 0
         @dimensions[i]=dimensions[i]
         @factors[i]=product
         product*=@dimensions[i]
         i-=1
      end
      @data=Array.new(product)
   end
  #--------------------------------------------------------------------------
  # * X Size
  #--------------------------------------------------------------------------
   def xsize
      return @dimensions[0]
   end
  #--------------------------------------------------------------------------
  # * Y Size
  #--------------------------------------------------------------------------
   def ysize
      return 1 if @dimensions.size<2
      return @dimensions[1]
   end
  #--------------------------------------------------------------------------
  # * Z Size
  #--------------------------------------------------------------------------
   def zsize
      return 1 if @dimensions.size<3
      return @dimensions[2]
   end
  #--------------------------------------------------------------------------
  # * NSize
  #--------------------------------------------------------------------------
   def nsize(n)
      raise IndexError if @dimensions.size<n
      return @dimensions[n-1]
   end
  #--------------------------------------------------------------------------
  # * Get ID
  #--------------------------------------------------------------------------
   def get_id(indices)
      raise IndexError if indices.size != @dimensions.size
      offset=0
      for i in 0 ... @dimensions.size
         raise IndexError if indices[i] < 0 or indices[i]>=@dimensions[i]
         offset += @factors[i]*indices[i]
      end
      return offset
   end
  #--------------------------------------------------------------------------
  # * Get []
  #--------------------------------------------------------------------------
   def [](*indices)
      @data[self.get_id(indices)]
   end
  #--------------------------------------------------------------------------
  # * Set []=
  #--------------------------------------------------------------------------
   def []=(*indicesAndValue)
      value = indicesAndValue.pop
      @data[self.get_id(indicesAndValue)]=value
   end
end
#==============================================================================
# ** 2-Dimensional Array
#    Creates a 2D array. When value not specified, returns 0. 
#==============================================================================
class Array2D
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize
    # Create Data Array
    @data = {}
  end
  #--------------------------------------------------------------------------
  # * Get
  #--------------------------------------------------------------------------
  def [](i,j)
    @data[i] = {} if @data[i].nil?
    @data[i][j] = 0 if @data[i][j].nil?
    return @data[i][j]
  end
  #--------------------------------------------------------------------------
  # * Set
  #--------------------------------------------------------------------------
  def []=(i,j,v)
    @data[i] = {} if @data[i].nil?
    @data[i][j] = v
    return v
  end
end
#==============================================================================
# ** RPG::Event::Page::Condition
#==============================================================================

class RPG::Event::Page::Condition
  #--------------------------------------------------------------------------
  # * Conditions Met?
  #--------------------------------------------------------------------------
  def conditions_met?(map_id, event_id)
    # Switch 1 condition confirmation
    if @switch1_valid && $game_switches[@switch1_id] == false
      return false
    end
    # Switch 2 condition confirmation
    if @switch2_valid && $game_switches[@switch2_id] == false
      return false
    end
    # Variable condition confirmation
    if @variable_valid && $game_variables[@variable_id] < @variable_value
      return false
    end
    # Self switch condition confirmation
    if @self_switch_valid
      key = [map_id, event_id, @self_switch_ch]
      if $game_self_switches[key] == false
        return false
      end
    end
    # Returns True
    return true
  end
end

#==============================================================================
# ** Game_Event
#==============================================================================
class Game_Event < Game_Character
  attr_reader :real_x, :real_y, :event
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    new_page = refresh_new_page               # Get New Page
    return if refresh_page_change?(new_page)  # Return if No Page Change
    clear_starting                            # Clear starting flag
    return if refresh_page_reset?             # Return if Nil Page Reset
    refresh_set_page                          # Set page variables
    refresh_check_process                     # Check parallel processing
    check_event_trigger_auto                  # Auto event start determinant
  end
  #--------------------------------------------------------------------------
  # * Refresh : New Page
  #--------------------------------------------------------------------------
  def refresh_new_page
    return @erased ? nil : refresh_trigger_conditions
  end
  #--------------------------------------------------------------------------
  # * Refresh Trigger Conditions
  #--------------------------------------------------------------------------
  def refresh_trigger_conditions
    # Check in order of large event pages
    for page in @event.pages.reverse
      # Skips If Page Conditions Not Met
      next unless page.condition.conditions_met?(@map_id, @id)
      # Set local variable: new_page
      new_page = page
      # Remove loop
      break
    end
    # Return new page
    return new_page
  end
  #--------------------------------------------------------------------------
  # * Refresh : Page Change
  #--------------------------------------------------------------------------
  def refresh_page_change?(new_page)
    # If event page is the same as last time
    if new_page == @page
      # End method
      return true
    end
    # Set @page as current event page
    @page = new_page
    return false
  end
  #--------------------------------------------------------------------------
  # * Refresh : Page Reset
  #--------------------------------------------------------------------------
  def refresh_page_reset?
    # If no page fulfills conditions
    if @page == nil
      # Reset values
      refresh_reset
      # End method
      return true
    end
    return false
  end
  #--------------------------------------------------------------------------
  # * Refresh Reset
  #--------------------------------------------------------------------------
  def refresh_reset
    # Set each instance variable
    @tile_id = 0
    @character_name = ""
    @character_hue = 0
    @move_type = 0
    @through = true
    @trigger = nil
    @list = nil
    @interpreter = nil
  end
  #--------------------------------------------------------------------------
  # * Refresh Set Page
  #--------------------------------------------------------------------------
  def refresh_set_page
    # Set each instance variable
    @tile_id = @page.graphic.tile_id
    @character_name = @page.graphic.character_name
    @character_hue = @page.graphic.character_hue
    if @original_direction != @page.graphic.direction
      @direction = @page.graphic.direction
      @original_direction = @direction
      @prelock_direction = 0
    end
    if @original_pattern != @page.graphic.pattern
      @pattern = @page.graphic.pattern
      @original_pattern = @pattern
    end
    @opacity = @page.graphic.opacity
    @blend_type = @page.graphic.blend_type
    @move_type = @page.move_type
    @move_speed = @page.move_speed
    @move_frequency = @page.move_frequency
    @move_route = @page.move_route
    @move_route_index = 0
    @move_route_forcing = false
    @walk_anime = @page.walk_anime
    @step_anime = @page.step_anime
    @direction_fix = @page.direction_fix
    @through = @page.through
    @always_on_top = @page.always_on_top
    @trigger = @page.trigger
    @list = @page.list
    @interpreter = nil
  end
  #--------------------------------------------------------------------------
  # * Refresh Check Process
  #--------------------------------------------------------------------------
  def refresh_check_process
    # If trigger is [parallel process]
    if @trigger == 4
      # Create parallel process interpreter
      @interpreter = Interpreter.new
    end
  end
end

class Interpreter
  #--------------------------------------------------------------------------
  # * Script
  #--------------------------------------------------------------------------
  def command_355
    # Set first line to script
    script = @list[@index].parameters[0] + "\n"
    # Loop
    loop do
      # If next event command is second line of script || after
      if @list[@index+1].code == 655
        # Add second line || after to script
        script += @list[@index+1].parameters[0] + "\n"
      # If event command is not second line || after
      else
        # Abort loop
        break
      end
      # Advance index
      @index += 1
    end
    # Evaluation
    result = eval(script)
    # Continue
    return true
  end
  #--------------------------------------------------------------------------
  # * In Range?(Element, Object, Range)
  #--------------------------------------------------------------------------
  def in_range?(element, object, range)
    x = (element.x - object.x)**2
    y = (element.y - object.y)**2
    return x + y <= (range * range)
  end
end

#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
#  This class performs load screen processing.
#==============================================================================

class Scene_Load < Scene_File
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Remake temporary object
    $game_temp = Game_Temp.new
    # Timestamp selects new file
    $game_temp.last_file_index = 0
    latest_time = Time.at(0)
    for i in 0..3
      filename = make_filename(i)
      if FileTest.exist?(filename)
        file = File.open(filename, "r")
        if file.mtime > latest_time
          latest_time = file.mtime
          $game_temp.last_file_index = i
        end
        file.close
      end
    end
    super("Which file would you like to load?")
  end
  #--------------------------------------------------------------------------
  # * Decision Processing
  #--------------------------------------------------------------------------
  def on_decision(filename)
    # If file doesn't exist
    unless FileTest.exist?(filename)
      # Play buzzer SE
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    # Play load SE
    $game_system.se_play($data_system.load_se)
    # Read save data
    file = File.open(filename, "rb")
    read_save_data(file)
    file.close
    # Restore BGM and BGS
    $game_system.bgm_play($game_system.playing_bgm)
    $game_system.bgs_play($game_system.playing_bgs)
    # Update map (run parallel process event)
    $game_map.update
    # Switch to map screen
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # * Cancel Processing
  #--------------------------------------------------------------------------
  def on_cancel
    # Play cancel SE
    $game_system.se_play($data_system.cancel_se)
    # Switch to title screen
    $scene = Scene_Title.new
  end
  #--------------------------------------------------------------------------
  # * Read Save Data
  #     file : file object for reading (opened)
  #--------------------------------------------------------------------------
  def read_save_data(file)
    read_characters(file)
    read_frame(file)
    read_data(file)
    read_edit
    read_refresh
  end
  #--------------------------------------------------------------------------
  # * Read Character Data
  #--------------------------------------------------------------------------
  def read_characters(file)
    # Read character data for drawing save file
    characters = Marshal.load(file)
  end
  #--------------------------------------------------------------------------
  # * Read Frame Count
  #--------------------------------------------------------------------------
  def read_frame(file)
    # Read frame count for measuring play time
    Graphics.frame_count = Marshal.load(file)
  end
  #--------------------------------------------------------------------------
  # * Read Data
  #--------------------------------------------------------------------------
  def read_data(file)
    # Read each type of game object
    $game_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    $game_variables     = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_screen        = Marshal.load(file)
    $game_actors        = Marshal.load(file)
    $game_party         = Marshal.load(file)
    $game_troop         = Marshal.load(file)
    $game_map           = Marshal.load(file)
    $game_player        = Marshal.load(file)
  end
  #--------------------------------------------------------------------------
  # * Read Edit
  #--------------------------------------------------------------------------
  def read_edit
    # If magic number is different from when saving
    # (if editing was added with editor)
    if $game_system.magic_number != $data_system.magic_number
      # Load map
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh Game Party
  #--------------------------------------------------------------------------
  def read_refresh
    # Refresh party members
    $game_party.refresh
  end
end
#==============================================================================
# ** Game_Character (part 1)
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player && Game_Event classes.
#==============================================================================
class Game_Character
  #--------------------------------------------------------------------------
  # * Get In Line
  #--------------------------------------------------------------------------
  def get_in_line(b)
    # Get difference in player coordinates
    sx = @x - b.x
    sy = @y - b.y    
    # If horizontal distance is longer
    if sx.abs > sy.abs
      # Turn to the right || left towards player
      if sx > 0
        # Pre Check
        if  passable?(@x, @y, 4)
          return move_left if pos_range?(@x-1,@y,b.x,b.y) >=  pos_range?(@x,@y,b.x,b.y) 
        else
          #return move_towards(b) if pos_range?(@x-1,@y,b.x,b.y) >=  pos_range?(@x,@y,b.x,b.y) 
        end
      else
        # Pre Check
        if passable?(@x, @y, 6)
          return move_right if pos_range?(@x+1,@y,b.x,b.y) >=  pos_range?(@x,@y,b.x,b.y) 
        else
          #return move_towards(b) if pos_range?(@x+1,@y,b.x,b.y) >=  pos_range?(@x,@y,b.x,b.y) 
        end
      end
      # Turn up || down towards player
      if sy > 0
        # Pre Check
        return move_up if pos_range?(@x,@y-1,b.x,b.y) >=  pos_range?(@x,@y,b.x,b.y) if  passable?(@x, @y, 8)
      else
        # Pre Check
        return move_down if pos_range?(@x,@y+1,b.x,b.y) >=  pos_range?(@x,@y,b.x,b.y) if  passable?(@x, @y, 2)
      end
    # If vertical distance is longer
    else
      # Turn up || down towards player
      if sy > 0
        # Pre Check
        return move_up if pos_range?(@x,@y-1,b.x,b.y) >=  pos_range?(@x,@y,b.x,b.y) if  passable?(@x, @y, 8)
      else
        # Pre Check
        return move_down if pos_range?(@x,@y+1,b.x,b.y) >=  pos_range?(@x,@y,b.x,b.y) if  passable?(@x, @y, 2)
      end
      # Turn to the right || left towards player
      if sx > 0
        # Pre Check
        if  passable?(@x, @y, 4)
          return move_left if pos_range?(@x-1,@y,b.x,b.y) >=  pos_range?(@x,@y,b.x,b.y) 
        else
          #return move_towards(b) if pos_range?(@x-1,@y,b.x,b.y) >=  pos_range?(@x,@y,b.x,b.y) 
        end
      else
        # Pre Check
        if  passable?(@x, @y, 6)
          return move_right if pos_range?(@x+1,@y,b.x,b.y) >=  pos_range?(@x,@y,b.x,b.y) 
        else
          #return move_towards(b) if pos_range?(@x+1,@y,b.x,b.y) >=  pos_range?(@x,@y,b.x,b.y) 
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Pos Range
  #--------------------------------------------------------------------------
  def pos_range?(x1,y1,x2,y2)
    x = (x1 - x2)**2
    y = (y1 - y2)**2
    r = x + y
    return Math.sqrt(r).to_i
  end
  #--------------------------------------------------------------------------
  # * Follow_Path
  #--------------------------------------------------------------------------
  def follow_path(x,y,&block)
    node = Node.new(x, y)
    path = A_Star_Pathfinder.new(node, self)
    path.reach_method = block
  end
  #--------------------------------------------------------------------------
  # * Turn Towards B
  #--------------------------------------------------------------------------
  def turn_to(b)
    # Get difference in player coordinates
    sx = @x - b.x
    sy = @y - b.y
    # If coordinates are equal
    if sx == 0 && sy == 0
      return
    end
    # If horizontal distance is longer
    if sx.abs > sy.abs
      # Turn to the right || left towards player
      sx > 0 ? turn_left : turn_right
    # If vertical distance is longer
    else
      # Turn up || down towards player
      sy > 0 ? turn_up : turn_down
    end
  end
  #--------------------------------------------------------------------------
  # * Move toward B
  #--------------------------------------------------------------------------
  def move_towards(b,ran=true)
    return if in_range2?(b,1) || !@a_star_path.nil?
    # Get difference in player coordinates
    sx = @x - b.x
    sy = @y - b.y
    @target = b
    # If coordinates are equal
    return if sx == 0 && sy == 0
    # Get absolute value of difference
    abs_sx = sx.abs
    abs_sy = sy.abs
    # If horizontal && vertical distances are equal
    if abs_sx == abs_sy
      # Increase one of them randomly by 1
      rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
    end
    # If horizontal distance is longer
    if abs_sx > abs_sy
      # Move towards player, prioritize left && right directions
      if sx > 0 
        return move_left if passable?(@x, @y, 4)
      else
        return move_right if passable?(@x, @y, 6)
      end
      if not moving? && sy != 0
        if sy > 0 
          return move_up if passable?(@x, @y, 8)
        else
          return move_down if passable?(@x, @y, 2)
        end
      end
    # If vertical distance is longer
    else
      # Move towards player, prioritize up && down directions
      if sy > 0 
        return move_up if passable?(@x, @y, 8) 
      else 
        return move_down if passable?(@x, @y, 2)
      end
      if not moving? && sx != 0
        if sx > 0 
          return move_left if passable?(@x, @y, 4)
        else
          return move_right if passable?(@x, @y, 6)
        end
      end
    end
=begin
    # Can't find the path, Try pathfidning
    if self.respond_to?(:a_star_path) && @a_star_path.nil?
      # Get X,Y
      x,y=b.x,b.y
      # Follow Path
      nx = x + (passable?(x-1,y,0) ? -1 : passable?(x+1,y,0) ? 1 : 0)
      ny = y + (passable?(x,y-1,0) ? -1 : passable?(x,y+1,0) ? 1 : 0)  
      self.follow_path(nx,ny)
      # Return if Path success
      return if !@a_star_path.nil? && @a_star_path.found
    end
=end
    if ran
      move_random
      turn_to(b)
    end
  end
  #--------------------------------------------------------------------------
  # * Move toward Pos XY
  #--------------------------------------------------------------------------
  def move_towards_pos(x,y,ran=true)
    # Get difference in player coordinates
    sx = @x - x
    sy = @y - y
    # If coordinates are equal
    return if sx == 0 && sy == 0
    # Get absolute value of difference
    abs_sx = sx.abs
    abs_sy = sy.abs
    # If horizontal && vertical distances are equal
    if abs_sx == abs_sy
      # Increase one of them randomly by 1
      rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
    end
    # If horizontal distance is longer
    if abs_sx > abs_sy
      # Move towards player, prioritize left && right directions
      if sx > 0 
        return move_left if passable?(@x, @y, 4)
      else
        return move_right if passable?(@x, @y, 6)
      end
      if not moving? && sy != 0
        if sy > 0 
          return move_up if passable?(@x, @y, 8)
        else
          return move_down if passable?(@x, @y, 2)
        end
      end
    # If vertical distance is longer
    else
      # Move towards player, prioritize up && down directions
      if sy > 0 
        return move_up if passable?(@x, @y, 8) 
      else 
        return move_down if passable?(@x, @y, 2)
      end
      if not moving? && sx != 0
        if sx > 0 
          return move_left if passable?(@x, @y, 4)
        else
          return move_right if passable?(@x, @y, 6)
        end
      end
    end
    if ran
      move_random
    end
  end
  #--------------------------------------------------------------------------
  # * Determine if Passable
  #     x : x-coordinate
  #     y : y-coordinate
  #     d : direction (0,2,4,6,8)
  #         * 0 = Determines if all directions are impassable (for jumping)
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    # Get new coordinates
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    return false if !check_map_pass(new_x,x,new_y,y,d)
    return false if !check_event_pass(new_x,new_y,d)
    return false if !check_player_pass(new_x,new_y,d)
    # passable
    return true
  end
  #--------------------------------------------------------------------------
  # * Check Map Pass
  #--------------------------------------------------------------------------
  def check_map_pass(new_x,x,new_y,y,d)
    # If coordinates are outside of map
    unless $game_map.valid?(new_x, new_y)
      # impassable
      return false
    end
    # If through is ON
    if @through
      # passable
      return true
    end
    # If unable to leave first move tile in designated direction
    unless $game_map.passable?(x, y, d, self)
      # impassable
      return false
    end
    # If unable to enter move tile in designated direction
    unless $game_map.passable?(new_x, new_y, 10 - d)
      # impassable
      return false
    end
    return true
  end
  #--------------------------------------------------------------------------
  # * Check Event Pass
  #--------------------------------------------------------------------------
  def check_event_pass(new_x,new_y,d)
    # Loop all events
    for event in $game_map.events.values
      # If event coordinates are consistent with move destination
      if event.x == new_x and event.y == new_y
        # If through is OFF
        unless event.through
          # If self is event
          if self_condition_player
            # impassable
            return false
          end
          # With self as the player and partner graphic as character
          if event.character_name != ""
            # impassable
            return false
          end
        end
      end
    end
    return true
  end
  #--------------------------------------------------------------------------
  # * Self Condition Player
  #--------------------------------------------------------------------------
  def self_condition_player
    bool = (self != $game_player)
    return bool
  end
  #--------------------------------------------------------------------------
  # * Check Player Pass
  #--------------------------------------------------------------------------
  def check_player_pass(new_x,new_y,d)
    # If player coordinates are consistent with move destination
    if $game_player.x == new_x and $game_player.y == new_y
      # If through is OFF
      unless $game_player.through
        # If your own graphic is the character
        if @character_name != ""
          # impassable
          return false
        end
      end
    end
    return true
  end
end

#==============================================================================
# ** Game_Map
#==============================================================================
class Game_Map
  def map; return @map; end
  #--------------------------------------------------------------------------
  # * Determine if Passable
  #     x          : x-coordinate
  #     y          : y-coordinate
  #     d          : direction (0,2,4,6,8,10)
  #                  *  0,10 = determine if all directions are impassable
  #     self_event : Self (If event is determined passable)
  #--------------------------------------------------------------------------
  def passable?(x, y, d, self_event = nil)
    # If coordinates given are outside of the map
    unless valid?(x, y)
      # impassable
      return false
    end
    # Change direction (0,2,4,6,8,10) to obstacle bit (0,1,2,4,8,0)
    bit = (1 << (d / 2 - 1)) & 0x0f
    # Pass Events
    pe = pass_events(bit,x,y,self_event)
    return pe unless pe.nil? 
    # Loop searches in order from top of layer
    for i in [2, 1, 0]
      # Get tile ID
      tile_id = data[x, y, i]
      # Tile ID acquistion failure
      if tile_id == nil
        # impassable
        return false
      # If obstacle bit is set
      elsif @passages[tile_id] & bit != 0
        # impassable
        return false
      # If obstacle bit is set in all directions
      elsif @passages[tile_id] & 0x0f == 0x0f
        # impassable
        return false
      # If priorities other than that are 0
      elsif @priorities[tile_id] == 0
        # passable
        return true
      end
    end
    # passable
    return true
  end
  #--------------------------------------------------------------------------
  # * Events
  #--------------------------------------------------------------------------
  def pass_events(bit,x,y,self_event)
    # Loop in all events
    for event in events.values
      # If tiles other than self are consistent with coordinates
      if event.tile_id >= 0 and event != self_event and
         event.x == x and event.y == y and not event.through
        # If obstacle bit is set
        if @passages[event.tile_id] & bit != 0
          # impassable
          return false
        # If obstacle bit is set in all directions
        elsif @passages[event.tile_id] & 0x0f == 0x0f
          # impassable
          return false
        # If priorities other than that are 0
        elsif @priorities[event.tile_id] == 0
          # passable
          return true
        end
      end
    end
    return nil
  end
end
module Input
  #---------------------------------------------------------------------------
  # * 4 Directions
  #---------------------------------------------------------------------------
  def Input.dir4
    return 2 if Input.repeat?(Input::DOWN) || Input.press?(Input::DOWN)
    return 4 if Input.repeat?(Input::LEFT) || Input.press?(Input::LEFT)
    return 6 if Input.repeat?(Input::RIGHT) || Input.press?(Input::RIGHT)
    return 8 if Input.repeat?(Input::UP) || Input.press?(Input::UP)
    0
  end
end
#==============================================================================
# ** Window_Horizantal
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_Horizantal < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width    : window width
  #     commands : command text string array
  #--------------------------------------------------------------------------
  def initialize(commands,height=32)
    # Get biggest Item
    bitmap = Bitmap.new(1,1); sz = 0
    commands.each { |c|
      i = bitmap.text_size(c).width
      sz = i if i > sz
    }
    @mw = sz+16
    # Compute window height from command quantity
    super(0, 0, commands.size * @mw + 32,height+32)
    @item_max = commands.size
    @column_max = @item_max
    @commands = commands
    self.contents = Bitmap.new(@item_max * @mw,height)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(@mw * index, 4, @mw, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index],1)
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set( @index * @mw, 4, @mw, self.height-32)
    end
  end
  #--------------------------------------------------------------------------
  # * Disable Item
  #     index : item number
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
end

Code:
#==============================================================================
# ** UCoders Message System - www.unknowncoders.com
#-------------------------------------------------------------------------------
# Author    Mr.Mo "Muhammet Sivri" | Trebor
# Version   1.0
# Date      12/05/07 (m/d/y)
#===============================================================================
class Game_System
  alias mrmo_settings_ms_system_initialize initialize
  def initialize
    mrmo_settings_ms_system_initialize
#===============================================================================
# ** Edit everything here OR in game using:
#       $game_system.variable_name = something
#    For example:
#       $game_system.letterBYletter = false
#------------------------------------------------------------------------------
#    You can edit some of these in the script editor using codes. 0 = off 1 = on
#------------------------------------------------------------------------------
#   Code List for everything is all the way down.
#===============================================================================
#===============================================================================
# * ////////////////////////////  EDIT BELOW ///////////////////////////////////
#===============================================================================
    @nameBox_opacity = 255      # Namebox Opacity
    
    @nameBox_to_window_opacity = false # Change namebox opacity to the message
                                       # window's opacity
                                       
    @letterBYletter = true      # Letter By Letter : false = show all at once
                                # Code: \lbl[0]
                                
    @letter_speed = 2           # Letter Speed IN frames 10f = 1 sec
                                # \ls[frames]
                                
    @player_skip = false         # Can the player skip by pressing action button?
                                # This will not effect TIME CLOSINGS!
                                # This only works for Letter BY Letter
                                # \ps[0]
                                
    @letter_se = ""#"033-Switch02" # Letter By Letter SE Leave "" to not play SE
                                # \lse[se_name] leave [] to not play SE
                                
    @window_x  = 80             # Message Window X Position
                                # \wx[pos]
                                
    @window_y  = 304            # Message Window Y Position
                                # \wy[pos]
                                
    @window_to_text = true     # Make Window size according to text
                                # \wt[0]
                                
    @message_width = 480        # Message Window Width
                                # \mw[width]
                                
    @message_height = 160       # Message Window height
                                # \mh[height]
                                       
    @message_font = Font.default_name  # Message Window Font
                                       # \ft[name]
                        
    @hover_message = true             # Allows the player to walk while message
                                       # is displayed.
                                       # \h
            
    @face_graphic = ""                 # No need to edit this here.
                                       # \fc[name]
                                       # Faces should be in picture folder.
                                       
    @face_justify = 0                  # 0 = left 1 = right
                                       # \fl = left \fr = right
                                       
    @battler_justify = 0               # 0 = left 1 = right
                                       # \bl = left \br = right
            
    @battler_graphic = ""              # No need to edit this here.
                                       # \bt[name]
                                       
    @multiple_windows = []             # Do not edit.
    
    @scrolling_text = nil              # Do not edit.
    
    @scroll_speed = 20                 # Scroll Speed in frames, higher the slower
    
    @auto_scroll = true                # Auto scroll without button input if true
                                       # if false, need button input to scroll
                                       # each message.
    
    @scroll_lines = 4                  # Number of lines to show, only if no auto scroll
    
    @close_on_display = false          # Do not edit. 
                                       # \cl
                                       
    @close_on_time = nil               # Do not edit. 
                                       # \ct[frames]
  end
 
@message_width = 480        # Message Window Width
                                # \mw[width]

you have to make that number smaller i would suggest to try 430 as start and if it is still too big, then make the number smaller again
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top