• 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 with making a Surf item

Minokun

The Rival in Space
107
Posts
10
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?
 
95
Posts
9
Years
  • Age 34
  • Seen Jun 18, 2016
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:

Bowlstir

Media Arts and Game Development
199
Posts
16
Years
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'.
 

Nickalooose

--------------------
1,309
Posts
16
Years
  • Seen Dec 28, 2023
You clearly followed an incomplete tutorial because you're missing a vital part of your script; def canUseMoveSurf?.

I suggest you make that.
 

Minokun

The Rival in Space
107
Posts
10
Years
  • Seen Sep 18, 2019
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?
})
 

Minokun

The Rival in Space
107
Posts
10
Years
  • Seen Sep 18, 2019
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..?
 

Minokun

The Rival in Space
107
Posts
10
Years
  • Seen Sep 18, 2019
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