• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Error] NoMethodError, but the method is an attribute.

#Not Important

All hail the wishmaker
910
Posts
4
Years
  • Code:
    [Pokémon Essentials version 18]
    Exception: RuntimeError
    Message: Script error within event 15 (coords 52,2), map 89 (Secret Base):
    Exception: NoMethodError
    Message: PokeBattle_SceneMenus:41:in `z='undefined method `z=' for nil:NilClass
    
    ***Full script:
    pbTrainerBattle(:TEAMNOIR_M,"Leonardo",_I("I'll tell the boss!"))
    
    Backtrace:
    Interpreter:201:in `pbExecuteScript'
    PokeBattle_SceneMenus:40:in `each'
    PokeBattle_SceneMenus:40:in `z='
    PokeBattle_SceneMenus:315:in `z='
    Spirit:1372:in `initialize'
    Scene_Initialize:45:in `new'
    Scene_Initialize:45:in `_bugContest_pbInitSprites'
    PokeBattle_BugContest:8:in `pbInitSprites'
    Scene_Initialize:21:in `pbStartBattle'
    Battle_StartAndEnd:270:in `pbStartBattleCore'
    
    
    Backtrace:
    Interpreter:237:in `pbExecuteScript'
    Interpreter:665:in `command_111'
    Interpreter:279:in `execute_command'
    Interpreter:155:in `update'
    Interpreter:102:in `loop'
    Interpreter:158:in `update'
    Scene_Map:162:in `update'
    Scene_Map:160:in `loop'
    Scene_Map:169:in `update'
    Scene_Map:229:in `main'
    That's the error, every sprite should have a z index, right?
    or do I need to define it?
    This is the code that's giving the error
    Code:
    	def initialize(viewport,z)
        super(viewport)
        self.x = 0
        self.y = Graphics.height-96
        @battler   = nil
        @shiftMode = 0
        # NOTE: @mode is for the display of the Mega Evolution button.
        #       0=don't show, 1=show unpressed, 2=show pressed
        if USE_GRAPHICS
          # Create bitmaps
          @buttonBitmap  = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_fight"))
          @typeBitmap    = AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
          @megaEvoBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_mega"))
    			@spiritbitmap   = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/Spirit_Power_Button"))
          @shiftBitmap   = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_shift"))
          # Create background graphic
          background = IconSprite.new(0,Graphics.height-96,viewport)
          background.setBitmap("Graphics/Pictures/Battle/overlay_fight")
          addSprite("background",background)
          # Create move buttons
          @buttons = Array.new(MAX_MOVES) do |i|
            button = SpriteWrapper.new(viewport)
            button.bitmap = @buttonBitmap.bitmap
            button.x      = self.x+4
            button.x      += (((i%2)==0) ? 0 : @buttonBitmap.width/2-4)
            button.y      = self.y+6
            button.y      += (((i/2)==0) ? 0 : BUTTON_HEIGHT-4)
            button.src_rect.width  = @buttonBitmap.width/2
            button.src_rect.height = BUTTON_HEIGHT
            addSprite("button_#{i}",button)
            next button
          end
          # Create overlay for buttons (shows move names)
          @overlay = BitmapSprite.new(Graphics.width,Graphics.height-self.y,viewport)
          @overlay.x = self.x
          @overlay.y = self.y
          pbSetNarrowFont(@overlay.bitmap)
          addSprite("overlay",@overlay)
          # Create overlay for selected move's info (shows move's PP)
          @infoOverlay = BitmapSprite.new(Graphics.width,Graphics.height-self.y,viewport)
          @infoOverlay.x = self.x
          @infoOverlay.y = self.y
          pbSetNarrowFont(@infoOverlay.bitmap)
          addSprite("infoOverlay",@infoOverlay)
          # Create type icon
          @typeIcon = SpriteWrapper.new(viewport)
          @typeIcon.bitmap = @typeBitmap.bitmap
          @typeIcon.x      = self.x+416
          @typeIcon.y      = self.y+20
          @typeIcon.src_rect.height = TYPE_ICON_HEIGHT
          addSprite("typeIcon",@typeIcon)
          # Create Mega Evolution button
          @megaButton = SpriteWrapper.new(viewport)
          @megaButton.bitmap = @megaEvoBitmap.bitmap
          @megaButton.x      = self.x+146
          @megaButton.y      = [email protected]/2
          @megaButton.src_rect.height = @megaEvoBitmap.height/2
          addSprite("megaButton",@megaButton)
    			# Create Spirit Power button
          @spiritButton = SpriteWrapper.new(viewport)
          @spiritButton.bitmap = @spiritbitmap.bitmap #i just realized i spelt 'bitmap' as 'bimap' dont bully
          @spiritButton.x      = self.x+146
          @spiritButton.y      = [email protected]/2
          @spiritButton.src_rect.height = @spiritbitmap.height/2
          addSprite("spiritButton",@spritButton)
          # Create Shift button
          @shiftButton = SpriteWrapper.new(viewport)
          @shiftButton.bitmap = @shiftBitmap.bitmap
          @shiftButton.x      = self.x+4
          @shiftButton.y      = [email protected]
          addSprite("shiftButton",@shiftButton)
        else
          # Create message box (shows type and PP of selected move)
          @msgBox = Window_AdvancedTextPokemon.newWithSize("",
             self.x+320,self.y,Graphics.width-320,Graphics.height-self.y,viewport)
          @msgBox.baseColor   = TEXT_BASE_COLOR
          @msgBox.shadowColor = TEXT_SHADOW_COLOR
          pbSetNarrowFont(@msgBox.contents)
          addSprite("msgBox",@msgBox)
          # Create command window (shows moves)
          @cmdWindow = Window_CommandPokemon.newWithSize([],
             self.x,self.y,320,Graphics.height-self.y,viewport)
          @cmdWindow.columns       = 2
          @cmdWindow.columnSpacing = 4
          @cmdWindow.ignore_input  = true
          pbSetNarrowFont(@cmdWindow.contents)
          addSprite("cmdWindow",@cmdWindow)
        end
        self.z=(z)
    		###################################################The error is here
      end
     
    Last edited:
    658
    Posts
    7
    Years
  • By putting z=(z), you're confusing the interpreter because it's taking "z=" as function name instead of an operation. It should be
    Code:
     self.z = z
     

    #Not Important

    All hail the wishmaker
    910
    Posts
    4
    Years
  • @spiritButton or @spiritButton.bitmap I think.
    Its default essentials apart from the @spiritButton and @spiritbitmap
    Edit: I spelt this part wrong (whoops)addSprite("spiritButton",@spritButton) I'll get back 2 u once I've tried it
     
    Last edited:
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Your thing is nil, it says so right in the error message.

    EDIT: Your typo might fix that. Not sure.
     
    971
    Posts
    7
    Years
    • Age 21
    • Seen Nov 28, 2022
    self.z = z is identical to self.z = (z) which is identical to self.z=(z). All you're doing is introducing spaces and parentheses, which don't change anything about it. z= is the method name, so that couldn't be a problem. Proof: self.method(:z=).call(z)
     
    Back
    Top