• 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.

[Essentials Tutorial] Turn HM moves into items

FL

Pokémon Island Creator
2,444
Posts
13
Years
  • Seen yesterday
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.
 
6
Posts
10
Years
  • Age 29
  • Seen Jul 20, 2018
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:

FL

Pokémon Island Creator
2,444
Posts
13
Years
  • Seen yesterday
After line 'def canUseMoveSurf?' you forget to add:

Code:
   terrain=Kernel.pbFacingTerrainTag
   notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
 
12
Posts
8
Years
  • Age 32
  • Seen Mar 8, 2016
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 http://www.pokecommunity.com/showthread.php?t=353829, that would be most appreciated =P
 

FL

Pokémon Island Creator
2,444
Posts
13
Years
  • Seen yesterday
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 http://www.pokecommunity.com/showthread.php?t=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:
6
Posts
10
Years
  • Age 29
  • Seen Jul 20, 2018
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:
 

FL

Pokémon Island Creator
2,444
Posts
13
Years
  • Seen yesterday
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!
 

fmw

2
Posts
8
Years
  • Age 31
  • Seen Oct 17, 2015
Could you please post the complete script for cut as i do not completely understand where to put it. Thanks!
 

FL

Pokémon Island Creator
2,444
Posts
13
Years
  • Seen yesterday
Could you please post the complete script for cut as i do not completely understand where to put it. Thanks!
This is already on main thread post, at "example" part.
 

fmw

2
Posts
8
Years
  • Age 31
  • Seen Oct 17, 2015
o I mean like the complete section for cut. Please I'm a terrible script-er! :)
 

FL

Pokémon Island Creator
2,444
Posts
13
Years
  • Seen yesterday
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!
 

FL

Pokémon Island Creator
2,444
Posts
13
Years
  • Seen yesterday
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
 

FL

Pokémon Island Creator
2,444
Posts
13
Years
  • Seen yesterday
I guess so. Some (like Fly) probably need adjustment.
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.
 
21
Posts
8
Years
  • Age 31
  • Seen May 1, 2016
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
})
 
30
Posts
8
Years
  • Age 27
  • Seen Jan 5, 2024
Can you do a better tutorial? I always get errors.. I'm using essentials 16.1
 

FL

Pokémon Island Creator
2,444
Posts
13
Years
  • Seen yesterday
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:
19
Posts
7
Years
  • Age 28
  • Seen Aug 10, 2020
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