• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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 with making a Surf item

Minokun

The Rival in Space
  • 107
    Posts
    11
    Years
    • Seen Sep 18, 2019
    When I tried to use a item I created to be a substitute for surf I got this error:

    ---------------------------
    Pokemon Rainbow & Shadow
    ---------------------------
    Exception: NoMethodError

    Message: undefined method `canUseMoveSurf?' for nil:NilClass

    PokemonItemEffects:136

    PokemonItemEffects:135:in `call'

    PBEvent:150:in `trigger'

    PokemonItems:177:in `triggerUseFromBag'

    PokemonItems:537:in `pbUseItem'

    PokemonBag:677:in `pbStartScreen'

    PokemonBag:651:in `loop'

    PokemonBag:716:in `pbStartScreen'

    PokemonPauseMenu:189:in `pbStartPokemonMenu'

    PokemonPauseMenu:188:in `pbFadeOutIn'



    This exception was logged in

    C:\Users\SharnJee\Saved Games/Pokemon Rainbow _ Shadow/errorlog.txt.

    Press Ctrl+C to copy this message to the clipboard.
    ---------------------------
    OK
    ---------------------------

    Any ideas?
     
    Welp, we don't have your code, so we can't help you, but it looks like you are calling a method that desn't exist.
     
    Last edited:
    Yeah it's basically impossible to see whats wrong without the rest of the coding for the item and it's effect.

    Tip:
    Always make back ups, and always remember what and where you added things one step at a time so you can easily go back and 'undo'.
     
    You clearly followed an incomplete tutorial because you're missing a vital part of your script; def canUseMoveSurf?.

    I suggest you make that.
     
    Sorry, Sorry, Sorry your right you can't read my mind! Here are the codes I altered.

    Code:
    HiddenMoveHandlers::CanUseMove.add(:SURF,proc{|move,pkmn|
    def canUseMoveSurf?
       terrain=Kernel.pbFacingTerrainTag
       notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
       if !$DEBUG &&
          !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
         Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
         return false
       end
       if $PokemonGlobal.surfing
         Kernel.pbMessage(_INTL("You're already surfing."))
         return false
       end
       if $game_player.pbHasDependentEvents?
         Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
         return false
       end
       if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
         Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
         return false
       end
       if !pbIsWaterTag?(terrain) || !notCliff
         Kernel.pbMessage(_INTL("No surfing here!"))
         return false
       end
       return true
     end
    })
    
    
    HiddenMoveHandlers::UseMove.add(:SURF,proc{|move,pokemon|
    def useMoveSurf
       if !pbHiddenMoveAnimation(nil)
         Kernel.pbMessage(_INTL("{1} used {2}!",$Trainer.name,PBMoves.getName(Surf)))
       end
       pbStartSurfing()
       return true
     end
    })

    And:

    Code:
    ItemHandlers::UseFromBag.add(:FLOATIE,proc{|item|
       next canUseMoveSurf? ? 2 : 0
    })
    
    ItemHandlers::UseInField.add(:FLOATIE,proc{|item|
       useMoveSurf if canUseMoveSurf?
    })
     
    Sorry, Sorry, Sorry your right you can't read my mind! Here are the codes I altered.

    Code:
    HiddenMoveHandlers::CanUseMove.add(:SURF,proc{|move,pkmn|
    [S-HIGHLIGHT]def canUseMoveSurf?[/S-HIGHLIGHT]
       terrain=Kernel.pbFacingTerrainTag
       notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
       if !$DEBUG &&
          !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
         Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
         return false
       end
       if $PokemonGlobal.surfing
         Kernel.pbMessage(_INTL("You're already surfing."))
         return false
       end
       if $game_player.pbHasDependentEvents?
         Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
         return false
       end
       if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
         Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
         return false
       end
       if !pbIsWaterTag?(terrain) || !notCliff
         Kernel.pbMessage(_INTL("No surfing here!"))
         return false
       end
       return true
     end
    })
    
    
    HiddenMoveHandlers::UseMove.add(:SURF,proc{|move,pokemon|
    def useMoveSurf
       if !pbHiddenMoveAnimation(nil)
         Kernel.pbMessage(_INTL("{1} used {2}!",$Trainer.name,PBMoves.getName(Surf)))
       end
       pbStartSurfing()
       return true
     end
    })

    And:

    Code:
    ItemHandlers::UseFromBag.add(:FLOATIE,proc{|item|
       next canUseMoveSurf? ? 2 : 0
    })
    
    ItemHandlers::UseInField.add(:FLOATIE,proc{|item|
       useMoveSurf if canUseMoveSurf?
    })

    Is this in the wrong place..?
     
    Yes, you procedure syntax is wrong. Delete 'HiddenMoveHandlers::CanUseMove.add(:SURF,proc{|move,pkmn|', 'HiddenMoveHandlers::UseMove.add(:SURF,proc{|move,pokemon|' and the '})'. I suggest you to take a look at my example.

    Oh, I thought you just cut that part out! My mistake (as always), thanks FL! {XD}
     
    Back
    Top