Unidentified modifier 'index' (Earthbound-ish Battle System Sprite Add-on)

Hey there! So when I add more than 5 characters for use with YanFly's party system, but when I do and enter a battle it shows me this:

Script 'Sprite Addon' line 131: NoMethodError occured.
undefined method 'index' for nil:NilClass
 

self.x = @battler.index * 128 + sx / 2 + 60 + 32 * (4 - $game_party.members.size)This is a weird error because this line determines the sprite's position. Any idea on how to fix this?

 

Code:
#==============================================================================# ** Earthbound-Ish Sprite Display#------------------------------------------------------------------------------# Version: 1.0# Author: cozziekuns # Date: February 17, 2013#==============================================================================# Description:#------------------------------------------------------------------------------# This script attempts to emulate the battle system of the Earthbound/Mother # series; most notably Earthbound and Earthbound 2 (Mother 2 and 3). This # certain addon addresses the character sprite movements found in Mother 3, # where active actors bobbed up and down the screen.#==============================================================================# Instructions:#------------------------------------------------------------------------------# Paste this script into its own slot in the Script Editor, above Main but # below Materials. #==============================================================================#==============================================================================# ** BattleManager#==============================================================================class << BattleManager    alias coz_ebishspd_btlmngr_init_members init_members  def init_members(*args)    coz_ebishspd_btlmngr_init_members(*args)    @dummy_battler = nil  end    def dummy_battler    @dummy_battler  end    def next_subject    loop do      battler = @action_battlers.shift      unless battler        @dummy_battler = nil        return nil      end      next unless battler.index && battler.alive?      @dummy_battler = battler      return battler    end  end  end#==============================================================================# ** Game_Actor#==============================================================================class Game_Actor    def use_sprite?    true  end  end#==============================================================================# ** Sprite_BattlerCharacter#==============================================================================class Sprite_BattlerCharacter < Sprite_Battler    def initialize(viewport, battler = nil)    super(viewport, battler)    @y_offset = 0  end    def make_animation_sprites    @ani_sprites = []    @ani_duplicated = @@ani_checker.include?(@animation)    if !@ani_duplicated && @animation.position == 3      @@ani_checker.push(@animation)    end  end    def update    super    update_position    update_zoom    update_y_offset  end    def update_bitmap    new_bitmap = set_character_bitmap    if bitmap != new_bitmap      self.bitmap = new_bitmap      init_visibility    end    update_src_rect  end    def set_character_bitmap    bitmap = Cache.character(@battler.character_name)    sign = @battler.character_name[/^[\!\$]./]    if sign && sign.include?('$')      @cw = bitmap.width / 3      @ch = bitmap.height / 4    else      @cw = bitmap.width / 12      @ch = bitmap.height / 8    end    self.ox = @cw / 2    self.oy = @ch    bitmap  end    def update_origin    if bitmap      self.ox = @cw / 2      self.oy = 0    end  end    def update_src_rect    index = @battler.character_index    sx = (index % 4 * 3 + 1) * @cw    sy = (index / 4 * 4) * @ch     self.src_rect.set(sx, sy, @cw, @y_offset)  end    def update_position    width = Graphics.width / ( 4 / $game_party.members.size.to_f )    sx = (Graphics.width - width) / 2 + 128    self.x = @battler.index * 128 + sx / 2 + 60 + 32 * (4 - $game_party.members.size)    self.y = 363 - @y_offset * 2   end    def update_zoom    self.zoom_x = 2.0    self.zoom_y = 2.0  end    def update_y_offset    if BattleManager.actor == @battler or BattleManager.dummy_battler == @battler      @y_offset = [@y_offset + 4, 32].min    else      @y_offset = [@y_offset - 4, 0].max    end  end  end#==============================================================================# ** Spriteset_Battle#==============================================================================class Spriteset_Battle    def create_actors    @actor_sprites = $game_party.members.collect { |actor|      Sprite_BattlerCharacter.new(@viewport3, actor)     }  end  end
Can you take a look at this value in YanFly's Script?

module YEA    module PARTY        MAX_BATTLE_MEMBERS   = 5        <...>    endend
If it's higher than 5, see if this is higher than 0:

Code:
MAX_MEMBERS_VARIABLE = 0
I made sure to set MAX_BATTLE_MEMBERS to 4, but I will look at the MAX_MEMBERS_VARIABLE when I get a chance.

EDIT: MAX_MEMBERS_VARIABLE is set to 0
You should set it to 6 or higher (whatever the number of actors is you can have in combat). If that number changes during gameplay, use the variable and modify it accordingly.
I want to have only 4 actors in combat, does it have to be 6+?
I want to have only 4 actors in combat, does it have to be 6+?
The problem is that the error you reported usually indicates that you have more than 4 battlers, because the sprites for the first four battlers are regular for the script.

And at the beginning you were talking about adding five characters...

If you have max battler set to four and still get the error, then most probably it's an incompatibility between the scripts - that the party system changes the way how the indices for the battle members are handled (automatically 1-4 in default), and that the sprite addon doesn't expect the way the party system handles the indices.
Ah I see how I was unclear. My plan was to have many actors that can be switched out, but you can only have 4 in a battle at a time. I think you're right about the scripts not being compatible though, thanks Andar!

Original thread: https://forums.rpgmakerweb.com/threads/unidentified-modifier-index-earthbound-ish-battle-system-sprite-add-on.39006/