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.

NoMethodError for conditional? [RESOLVED!]

Upon writting my Order command, I keep getting an error on this line

Code:
def update_status
  #..Some code
  if @actor01 < @actor02
    #...Does something
  end
  #...More code
end

The error it pops is...

NoMethodError":381m9qpy said:
Script 'CMS::Scene_Menu' line 389: NoMethodError occured
undefined method '<' for#<Window_Base:0x29a12a8>

For one, its not supposed to be a method, its defined within a method... I don't know what this error is trying to tell me.

Any idea why it would pop such a weird error?

This is the actual portion of the script, if you need to look at it (search for '# KN: Error', its that line.)

Code:
class Scene_Menu

  #Other stuff

  #------------------------
  # * Update Status Method
  #------------------------
  def update_status
    # If C button is pressed
    if Input.trigger?(Input::C) or Input.trigger?(Input::RIGHT)
      # Play Decision SE
      $game_system.se_play($data_system.decision_se)
      case @window_command.index
      
      # Other stuff

      when CMS_Index_Order
        if Input.trigger?(Input::B)
          # Unless the actor isn't nil
          unless @actor01 != nil
            # Play Decision SE
            $game_system.se_play($data_system.decision_se)
            @window_command.active = true
            @window_status.active = false
            @window_status.index = -1
            return
          end
          @actor01 = nil
          return
        end
        # [If C button is pressed]----------------------------------------------
        if Input.trigger?(Input::C)
          # Unless Actor01 is nil
          unless @actor01 != nil
            # Play Decision SE
            $game_system.se_play($data_system.decision_se)
            # Status index determines first actor to swap
            @actor01 = @window_status.index
            return
          end
          # If Actor01 is equal to the Status Window's Index
          if @actor01 == @window_status.index
            # Play Decision SE
            $game_system.se_play($data_system.decision_se)
            # Actor01 is nil
            @actor01 = nil
            return
          end
          party = []
          # For the actor within the Game Party's actor array.
          for actor in $game_party.actors
            party.push(actor.id)
          end
          # Actor02 is equal to the Status Window's Index
          actor02 = @window_status.index
          # If Actor01's index is less than Actor02's index
          if @actor01 < actor02 # KN: Error
            # For information in Actor01 index vs party size
            for i in @actor01...party.size
              # Remove Actor
              $game_party.remove_actor(party[i])
            end
            # Add Actor02 to the party
            $game_party.add_actor(party[actor02])
            # For the information in the Actor01 within the party size
            for i in (@actor01 + 1)...party.size
              # If Actor01 and Actor02 is the same actor
              unless i == actor02
                # Add current actor
                $game_party.add_actor(party[i])
              else
                # Add Actor01
                $game_party.add_actor(party[@actor01])
              end
            end
          else
            # For information Actor02 within the party size
            for i in actor02...party.size
              # Remove Actor
              $game_party.remove_actor(party[i])
            end
            # Add Actor01 to the party
            $game_party.add_actor(party[@actor01])
            # For the information in Actor02 within the game party
            for i in (actor02 + 1)...party.size
              # If Actor01 and Actor02 is the same actor
              unless i == @actor01
                # Add current actor
                $game_party.add_actor(party[i])
              else
                # Add Actor02
                $game_party.add_actor(party[actor02])
              end
            end
          end
          # Actor01 is returned as nil
          @actor01 = nil
          # Refresh the Status Window
          @window_status.refresh
          return
        end
        # If pressing LEFT or RIGHT
        if Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
          # If the Actor01 is nil and Window_Command's index is 'Order'
          if @actor01 == nil and @window_command.index == CMS_Index_Order
            $game_system.se_play($data_system.cursor_se)
            @window_command.active = true
            @window_command.index = CMS_Index_Order
            @window_status.active = false
            @window_status.index = -1
          end
        end
      end
    end
  end
end
 

hosaii

Member

It tells you either @actor01 or @actor02 contain a window not a number. I don't see you have @actor02 here. So it is possibly caused by other reason. Just check whether you have some code like this in the script: @actor02 = Window_Base.new
 
Okay, I found it... in the top of the script, I call dummy windows, @actor01, @actor02, @actor03, @actor04... that must've overwritten the @actor01 and @actor02 that was meant to be an 'actor' later on in the scene.

I simply changed the @actor01 and 02 for the 'window' variable to @w_actor01 and it fixed it!

Thanks!
 

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