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.

Script error

Smaug

Member

I'm getting this error when calling a battle:
Script 'Main' line 17:NoMethodError occured.

undefined method 'main for #<Scene_Battle:0x1612ae0>


and this is my main:
Code:
#==============================================================================
# ** Main
#------------------------------------------------------------------------------
#  After defining each class, actual processing begins here.
#==============================================================================

begin
Font.default_name = "Franklin Gothic Medium"
Font.default_bold = true
#"Font.default_color = "blue"
  # Prepare for transition
  Graphics.freeze
  # Make scene object (title screen)
  $scene = Scene_Title.new
  # Call main method as long as $scene is effective
  while $scene != nil
    $scene.main
  end
  # Fade out
  Graphics.transition(20)
rescue Errno::ENOENT
  # Supplement Errno::ENOENT exception
  # If unable to open file, display message and end
  filename = $!.message.sub("No such file or directory - ", "")
  print("Unable to find file #{filename}.")
end


Maybe it has to do something with this:

Code:
#==============================================================================
# â–  Window_Selectable
#------------------------------------------------------------------------------
#  カーソルの移動やスクロールの機能を持つウィンドウクラスです。
#==============================================================================

class Window_Selectable2< Window_Base
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader   :index                    # カーソル位置
  attr_reader   :help_window              # ヘルプウィンドウ
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     x      : ウィンドウの X 座標
  #     y      : ウィンドウの Y 座標
  #     width  : ウィンドウの幅
  #     height : ウィンドウの高さ
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @item_max = 1
    @column_max = 1
    @index = -1
  end
  #--------------------------------------------------------------------------
  # ● カーソル位置の設定
  #     index : 新しいカーソル位置
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    # ヘルプテキストを更新 (update_help は継承先で定義される)
    if self.active and @help_window != nil
      update_help
    end
    # カーソルの矩形を更新
  end
  #--------------------------------------------------------------------------
  # ● 行数の取得
  #--------------------------------------------------------------------------
  def row_max
    # é …ç›®æ•°ã¨åˆ—æ•°ã‹ã‚‰è¡Œæ•°ã‚’ç®—å‡º
    return (@item_max + @column_max - 1) / @column_max
  end
  #--------------------------------------------------------------------------
  # ● å…ˆé ­ã®è¡Œã®å–å¾—
  #--------------------------------------------------------------------------
  def top_row
    # ウィンドウ内容の転送元 Y 座標を、1 行の高さ 32 で割る
    return self.oy / 32
  end
  #--------------------------------------------------------------------------
  # ● å…ˆé ­ã®è¡Œã®è¨­å®š
  #     row : å…ˆé ­ã«è¡¨ç¤ºã™ã‚‹è¡Œ
  #--------------------------------------------------------------------------
  def top_row=(row)
    # row が 0 æœªæº€ã®å ´åˆã¯ 0 に修正
    if row < 0
      row = 0
    end
    # row が row_max - 1 è¶…ã®å ´åˆã¯ row_max - 1 に修正
    if row > row_max - 1
      row = row_max - 1
    end
    # row に 1 行の高さ 32 を掛け、ウィンドウ内容の転送元 Y 座標とする
    self.oy = row * 32
  end
  #--------------------------------------------------------------------------
  # ● 1 ページに表示できる行数の取得
  #--------------------------------------------------------------------------
  def page_row_max
    # ウィンドウの高さから、フレームの高さ 32 を引き、1 行の高さ 32 で割る
    return (self.height - 32) / 32
  end
  #--------------------------------------------------------------------------
  # ● 1 ãƒšãƒ¼ã‚¸ã«è¡¨ç¤ºã§ãã‚‹é …ç›®æ•°ã®å–å¾—
  #--------------------------------------------------------------------------
  def page_item_max
    # 行数 page_row_max に 列数 @column_max を掛ける
    return page_row_max * @column_max
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの設定
  #     help_window : 新しいヘルプウィンドウ
  #--------------------------------------------------------------------------
  def help_window=(help_window)
    @help_window = help_window
    # ヘルプテキストを更新 (update_help は継承先で定義される)
    if self.active and @help_window != nil
      update_help
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    # ã‚«ãƒ¼ã‚½ãƒ«ã®ç§»å‹•ãŒå¯èƒ½ãªçŠ¶æ…‹ã®å ´åˆ
    if self.active and @item_max > 0 and @index >= 0
      # æ–¹å‘ãƒœã‚¿ãƒ³ã®ä¸‹ãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
      if Input.repeat?(Input::DOWN)
        # 列数が 1 かつ æ–¹å‘ãƒœã‚¿ãƒ³ã®ä¸‹ã®æŠ¼ä¸‹çŠ¶æ…‹ãŒãƒªãƒ”ãƒ¼ãƒˆã§ãªã„å ´åˆã‹ã€
        # またはカーソル位置が(é …ç›®æ•° - 列数)ã‚ˆã‚Šå‰ã®å ´åˆ
        if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
           @index < @item_max - @column_max
          # カーソルを下に移動
          $game_system.se_play($data_system.cursor_se)
          @index = (@index + @column_max) % @item_max
        end
      end
      # æ–¹å‘ãƒœã‚¿ãƒ³ã®ä¸ŠãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
      if Input.repeat?(Input::UP)
        # 列数が 1 かつ æ–¹å‘ãƒœã‚¿ãƒ³ã®ä¸Šã®æŠ¼ä¸‹çŠ¶æ…‹ãŒãƒªãƒ”ãƒ¼ãƒˆã§ãªã„å ´åˆã‹ã€
        # ã¾ãŸã¯ã‚«ãƒ¼ã‚½ãƒ«ä½ç½®ãŒåˆ—æ•°ã‚ˆã‚Šå¾Œã‚ã®å ´åˆ
        if (@column_max == 1 and Input.trigger?(Input::UP)) or
           @index >= @column_max
          # カーソルを上に移動
          $game_system.se_play($data_system.cursor_se)
          @index = (@index - @column_max + @item_max) % @item_max
        end
      end
      # æ–¹å‘ãƒœã‚¿ãƒ³ã®å³ãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
      if Input.repeat?(Input::RIGHT)
        # 列数が 2 以上で、カーソル位置が(é …ç›®æ•° - 1)ã‚ˆã‚Šå‰ã®å ´åˆ
        if @column_max >= 2 and @index < @item_max - 1
          # カーソルを右に移動
          $game_system.se_play($data_system.cursor_se)
          @index += 1
        end
      end
      # æ–¹å‘ãƒœã‚¿ãƒ³ã®å·¦ãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
      if Input.repeat?(Input::LEFT)
        # 列数が 2 以上で、カーソル位置が 0 ã‚ˆã‚Šå¾Œã‚ã®å ´åˆ
        if @column_max >= 2 and @index > 0
          # カーソルを左に移動
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
        end
      end
      # R ãƒœã‚¿ãƒ³ãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
      if Input.repeat?(Input::R)
        # è¡¨ç¤ºã•ã‚Œã¦ã„ã‚‹æœ€å¾Œå°¾ã®è¡ŒãŒã€ãƒ‡ãƒ¼ã‚¿ä¸Šã®æœ€å¾Œã®è¡Œã‚ˆã‚Šã‚‚å‰ã®å ´åˆ
        if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
          # カーソルを 1 ページ後ろに移動
          $game_system.se_play($data_system.cursor_se)
          @index = [@index + self.page_item_max, @item_max - 1].min
          self.top_row += self.page_row_max
        end
      end
      # L ãƒœã‚¿ãƒ³ãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
      if Input.repeat?(Input::L)
        # è¡¨ç¤ºã•ã‚Œã¦ã„ã‚‹å…ˆé ­ã®è¡ŒãŒ 0 ã‚ˆã‚Šå¾Œã‚ã®å ´åˆ
        if self.top_row > 0
          # カーソルを 1 ページ前に移動
          $game_system.se_play($data_system.cursor_se)
          @index = [@index - self.page_item_max, 0].max
          self.top_row -= self.page_row_max
        end
      end
    end
    # ヘルプテキストを更新 (update_help は継承先で定義される)
    if self.active and @help_window != nil
      update_help
    end
    # カーソルの矩形を更新
  end
  end
 

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