• 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!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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.

[Essentials Tutorial] Turn HM moves into items

i am getting this message for when making a surfboard as an item, i do not know what i am doing wrong i followed everything, can anyone offer help? am i not seeing my mistake?

---------------------------
Pokemon Essentials
---------------------------
Exception: NameError

Message: undefined local variable or method `terrain' for nil:NilClass

PokemonHiddenMoves:455:in `canUseMoveSurf?'

PokemonItemEffects:131

PokemonItemEffects:130:in `call'

PBEvent:150:in `trigger'

PokemonItems:165:in `triggerUseFromBag'

PokemonItems:520:in `pbUseItem'

PokemonBag:677:in `pbStartScreen'

PokemonBag:651:in `loop'

PokemonBag:716:in `pbStartScreen'

PokemonPauseMenu:189:in `pbStartPokemonMenu'



This exception was logged in
Post your changes.
 
Post your changes.
This is what i edited for the surf in PokemonHiddenMoves

Code:
def Kernel.pbSurf
  if $game_player.pbHasDependentEvents?
    return false
  end
  if $DEBUG ||
    (HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
    movefinder=Kernel.pbCheckMove(:SURF)
    if $DEBUG || $PokemonBag.pbQuantity(PBItems::SURFBOARD)>0
      if Kernel.pbConfirmMessage(_INTL("The tides look nasty would you like to go surfing?"))
        speciesname=!movefinder ? $Trainer.name : movefinder.name
        Kernel.pbMessage(_INTL("You started surfing!",speciesname))
        
        surfbgm=pbGetMetadata(0,MetadataSurfBGM)
        if surfbgm
          pbCueBGM(surfbgm,0.5)
        end
        pbStartSurfing()
        return true
      end
    end
  end
  return false
end

def pbStartSurfing()
  Kernel.pbCancelVehicles
  $PokemonEncounters.clearStepCount
  $PokemonGlobal.surfing=true
  Kernel.pbUpdateVehicle
  Kernel.pbJumpToward
  Kernel.pbUpdateVehicle
  $game_player.check_event_trigger_here([1,2])
end

def pbEndSurf(xOffset,yOffset)
  return false if !$PokemonGlobal.surfing
  x=$game_player.x
  y=$game_player.y
  currentTag=$game_map.terrain_tag(x,y)
  facingTag=Kernel.pbFacingTerrainTag
  if pbIsSurfableTag?(currentTag) && !pbIsSurfableTag?(facingTag)
    if Kernel.pbJumpToward
      Kernel.pbCancelVehicles
      $game_map.autoplayAsCue
      $game_player.increase_steps
      result=$game_player.check_event_trigger_here([1,2])
      Kernel.pbOnStepTaken(result)
    end
    return true
  end
  return false
end

Events.onAction+=proc{|sender,e|
   terrain=Kernel.pbFacingTerrainTag
   notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
   if pbIsWaterTag?(terrain) && !$PokemonGlobal.surfing && 
      !pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && notCliff
     Kernel.pbSurf
     return
   end
}
def canUseMoveSurf?
  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
def UseMoveSurf
  if !pbHiddenMoveAnimation(nil)
     Kernel.pbMessage(_INTL("{1} used {2}!",$Trainer.name,PBMoves.getName(Surf)))
   end
   pbStartSurfing()
   return true
end

#HiddenMoveHandlers::CanUseMove.add(:SURF,proc{|move,pkmn|
#   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
#})

HiddenMoveHandlers::UseMove.add(:SURF,proc{|move,pokemon|
   if !pbHiddenMoveAnimation(pokemon)
     Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
   end
   pbStartSurfing()
   return true
})


This is in PokemonItemEffects

Code:
ItemHandlers::UseInField.add(:SURFBOARD,proc{|item|
   useMoveSurf if canUseMoveSurf?
})

ItemHandlers::UseFromBag.add(:SURFBOARD,proc{|item|
   next canUseMoveSurf? ? 2 : 0
})

and this is in my PBS for items

526, SURFBOARD, Surfboard, 8, 0, The perfect board for shredding the gnar.,2,0,6


The error message pops up when i am standing facing water, and go into my bag and click use on the surfboard, any help is appreciated thanks!
 
Last edited by a moderator:
Is there any way to, instead of activating the move from an item, activating it from an event?? Like, talking to a rocket and calling the Fly menu, interacting with a ship to start surfing or touching a scuba to dive the sea?

Also, if you could answer this question I present here https://www.pokecommunity.com/threads/353829, that would be most appreciated =P
 
Is there any way to, instead of activating the move from an item, activating it from an event?? Like, talking to a rocket and calling the Fly menu, interacting with a ship to start surfing or touching a scuba to dive the sea?

Also, if you could answer this question I present here https://www.pokecommunity.com/threads/353829, that would be most appreciated =P
I guess that you only need to copy the content on 'UseInField' and paste into a script event command.

I replied at your thread.
 
Last edited:
Thank you for looking through my coding mistake, but that add on seemed to generate another, here is the new problem that occurred:

Spoiler:


I can see it is referring to the item section with clicking use on the surfboard in the bag, here is my code for that

Spoiler:


finally just so its here if it needs changing this is my surf section code

Spoiler:
 
Thank you for looking through my coding mistake, but that add on seemed to generate another, here is the new problem that occurred:

Spoiler:


I can see it is referring to the item section with clicking use on the surfboard in the bag, here is my code for that

Spoiler:


finally just so its here if it needs changing this is my surf section code

Spoiler:
Every time that you repost the code, please use the code tag!

'Kernel.pbMessage(_INTL("You started surfing!",$Trainer.name,"Surf"))' as is the purpose of using three parameters as _INTL without the place to replace on main message?

Are you sure that you typed 'useMoveSurf' and not 'UseMoveSurf' in both places? Ruby is case sensitive!
 
Could you please post the complete script for cut as i do not completely understand where to put it. Thanks!
 
o I mean like the complete section for cut. Please I'm a terrible script-er! :)
 
o I mean like the complete section for cut. Please I'm a terrible script-er! :)
The first code part goes into item.txt, the second goes into PokemonHiddenMoves script section and the last goes into PokemonItemEffects script section. Just copy and paste the code!
 
I tried to turn teleport into an item but it is different from others, how can i make it?
The only diference is that the confirmation message show ups twice if you use by item menu. To fix this, change

Code:
     mapname=pbGetMapNameFromId(healing[0])
     if Kernel.pbConfirmMessage(_INTL("Want to return to the healing spot used last in {1}?",mapname))
       return true
     end
     return false

into 'return true'. And add after 'if healing' (in useMoveTeleport):

Code:
     mapname=pbGetMapNameFromId(healing[0])
     if !Kernel.pbConfirmMessage(_INTL("Want to return to the healing spot used last in {1}?",mapname))
       return false
     end
 
After testing, the only adjustment was the plural field when declaring items.

But using Surf from menu won't work in Essentials V16.1, so it won't work here too.

Surf will work from the bag. You just need to fix outdated code.
Try out the script below and let me know if it works. It should, it does for me with v16.1

Code:
#===============================================================================
# Surf
#===============================================================================
def Kernel.pbSurf
if $game_player.pbHasDependentEvents?
return false
end
if $DEBUG ||
(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
movefinder=Kernel.pbCheckMove(:SURF)
if $DEBUG || $PokemonBag.pbQuantity(PBItems::RAFT)>0
if Kernel.pbConfirmMessage(_INTL("The water is a deep blue, would you like to use the raft?"))
speciesname=!movefinder ? $Trainer.name : movefinder.name
Kernel.pbMessage(_INTL("You started rafting!",speciesname))

surfbgm=pbGetMetadata(0,MetadataSurfBGM)
if surfbgm
pbCueBGM(surfbgm,0.5)
end

pbStartSurfing()
return true
end
end
end
return false
end

def pbStartSurfing()
Kernel.pbCancelVehicles
$PokemonEncounters.clearStepCount
$PokemonGlobal.surfing=true
Kernel.pbUpdateVehicle
Kernel.pbJumpToward
Kernel.pbUpdateVehicle
$game_player.check_event_trigger_here([1,2])
end

def pbEndSurf(xOffset,yOffset)
return false if !$PokemonGlobal.surfing
x=$game_player.x
y=$game_player.y
currentTag=$game_map.terrain_tag(x,y)
facingTag=Kernel.pbFacingTerrainTag
if pbIsSurfableTag?(currentTag) && !pbIsSurfableTag?(facingTag)
if Kernel.pbJumpToward
Kernel.pbCancelVehicles
$game_map.autoplayAsCue
$game_player.increase_steps
result=$game_player.check_event_trigger_here([1,2])
Kernel.pbOnStepTaken(result)
end
return true
end
return false
end

Events.onAction+=proc{|sender,e|
terrain=Kernel.pbFacingTerrainTag
notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
if pbIsWaterTag?(terrain) && !$PokemonGlobal.surfing && 
!pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && notCliff
Kernel.pbSurf
return
end
}
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 rafting."))
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 !PBTerrain.isSurfable?(terrain) || !notCliff
if !pbIsWaterTag?(terrain) || !notCliff
Kernel.pbMessage(_INTL("No rafting here!"))
return false
end
return true
end

def useMoveSurf
if !pbHiddenMoveAnimation(nil)
Kernel.pbMessage(_INTL("You started rafting!",$Trainer.name,"Surf"))
end
pbStartSurfing()
return true
end

HiddenMoveHandlers::UseMove.add(:SURF,proc{|move,pokemon|
if !pbHiddenMoveAnimation(pokemon)
Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
end
pbStartSurfing()
return true
})
 
Can you do a better tutorial? I always get errors.. I'm using essentials 16.1
 
Can you do a better tutorial? I always get errors.. I'm using essentials 16.1
I need a better feedback that "do a better tutorial". This isn't an easy modification. You need to know what is a procedure/method start and end. Fortunately, I put an example, so, even if you get confused in some part, you can look in this example.

Even, there some moves that are exceptions as I mentioned before with Fly.

Like I said before, I tested this tutorial with the latest versions.

EDIT: I detailed the example a little more.
 
Last edited:
Hi I'm getting this error:

"Script 'PField_HiddenMoves' line 506: SyntaxError occurred."

Here are the things i changed:

Surf.
Spoiler:


Waterfall.
Spoiler:


Dive.
Spoiler:
 
Back
Top