- 195
- Posts
- 8
- Years
- Seen Apr 20, 2025
View attachment 81311
View attachment 81312
Well I tried and it causes another error. Unless I did something stupid.
if $PokemonGlobal.flashUsed
Kernel.pbMessage(_INTL("This is already in use"))
return false
[COLOR="Red"]end[/COLOR]
return true
You're missing an end for your if
Code:if $PokemonGlobal.flashUsed Kernel.pbMessage(_INTL("This is already in use")) return false [COLOR="Red"]end[/COLOR] return true
I tested right now and the method is equals to Cut one. It's even easier, since Flash can't be used outside menu.Ok, as I see my previous edit didn't really get an answer, I'll double-post (though I don't want to).
So what I got given when I asked for help getting an alternative (in item form) for Flash was the base code for it. I must have been misunderstood then so I'm clearing it up. Now, can anyone help me with the code for a working Flash item?
605,LANTERN,Lantern,Lanterns,8,0,"A lantern that illuminate caves.",2,0,6
HiddenMoveHandlers::CanUseMove.add(:FLASH,proc{|move,pkmn|
if !$DEBUG &&
!(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORFLASH])
Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
return false
end
if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
Kernel.pbMessage(_INTL("Can't use that here."))
return false
end
if $PokemonGlobal.flashUsed
Kernel.pbMessage(_INTL("This is in use already."))
return false
end
return true
})
HiddenMoveHandlers::UseMove.add(:FLASH,proc{|move,pokemon|
darkness=$PokemonTemp.darknessSprite
return false if !darkness || darkness.disposed?
if !pbHiddenMoveAnimation(pokemon)
Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
end
$PokemonGlobal.flashUsed=true
while darkness.radius<176
Graphics.update
Input.update
pbUpdateSceneMap
darkness.radius+=4
end
return true
})
def canUseMoveFlash?
if !$DEBUG &&
!(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORFLASH])
Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
return false
end
if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
Kernel.pbMessage(_INTL("Can't use that here."))
return false
end
if $PokemonGlobal.flashUsed
Kernel.pbMessage(_INTL("This is in use already."))
return false
end
return true
end
def useMoveFlash
darkness=$PokemonTemp.darknessSprite
return false if !darkness || darkness.disposed?
if !pbHiddenMoveAnimation(nil)
Kernel.pbMessage(_INTL("{1} used {2}!",$Trainer.name,"Flash"))
end
$PokemonGlobal.flashUsed=true
while darkness.radius<176
Graphics.update
Input.update
pbUpdateSceneMap
darkness.radius+=4
end
return true
end
ItemHandlers::UseFromBag.add(:LANTERN,proc{|item|
next canUseMoveFlash? ? 2 : 0
})
ItemHandlers::UseInField.add(:LANTERN,proc{|item|
useMoveFlash if canUseMoveFlash?
})
I tested right now and the method is equals to Cut one. It's even easier, since Flash can't be used outside menu.
The code:
Code:605,LANTERN,Lantern,Lanterns,8,0,"A lantern that illuminate caves.",2,0,6
I copied the two HiddenMoveHandlers below (these are in base Essentials):
Code:HiddenMoveHandlers::CanUseMove.add(:FLASH,proc{|move,pkmn| if !$DEBUG && !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORFLASH]) Kernel.pbMessage(_INTL("Sorry, a new Badge is required.")) return false end if !pbGetMetadata($game_map.map_id,MetadataDarkMap) Kernel.pbMessage(_INTL("Can't use that here.")) return false end if $PokemonGlobal.flashUsed Kernel.pbMessage(_INTL("This is in use already.")) return false end return true }) HiddenMoveHandlers::UseMove.add(:FLASH,proc{|move,pokemon| darkness=$PokemonTemp.darknessSprite return false if !darkness || darkness.disposed? if !pbHiddenMoveAnimation(pokemon) Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move))) end $PokemonGlobal.flashUsed=true while darkness.radius<176 Graphics.update Input.update pbUpdateSceneMap darkness.radius+=4 end return true })
For making the two methods below. I added after the handlers:
Code:def canUseMoveFlash? if !$DEBUG && !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORFLASH]) Kernel.pbMessage(_INTL("Sorry, a new Badge is required.")) return false end if !pbGetMetadata($game_map.map_id,MetadataDarkMap) Kernel.pbMessage(_INTL("Can't use that here.")) return false end if $PokemonGlobal.flashUsed Kernel.pbMessage(_INTL("This is in use already.")) return false end return true end def useMoveFlash darkness=$PokemonTemp.darknessSprite return false if !darkness || darkness.disposed? if !pbHiddenMoveAnimation(nil) Kernel.pbMessage(_INTL("{1} used {2}!",$Trainer.name,"Flash")) end $PokemonGlobal.flashUsed=true while darkness.radius<176 Graphics.update Input.update pbUpdateSceneMap darkness.radius+=4 end return true end
And I added at PokemonItemEffects script section:
Code:ItemHandlers::UseFromBag.add(:LANTERN,proc{|item| next canUseMoveFlash? ? 2 : 0 }) ItemHandlers::UseInField.add(:LANTERN,proc{|item| useMoveFlash if canUseMoveFlash? })
Did you tried the described on latest posts?Thanks very much, it's 100% working! :)
Whilst we're still on the subject, I've tried out your surf one and it no longer works, something about pbIsWaterTag?
Did you tried the described on latest posts?
Try the Vernerl code (with the commented changes).Yes, I did. Here, this is a clearer way of me showing you the issue.
Try the Vernerl code (with the commented changes).
with the commented changes of the following posts.Isn't the code on that broken?
with the commented changes of the following posts.
I read the codes again and you was right. Changing 'pbIsWaterTag?(terrain)' to 'PBTerrain.isSurfable?(terrain)' should fix these problems.I used that code and I got the error I posted before. pbWaterTag isn't being found.
I read the codes again and you was right. Changing 'pbIsWaterTag?(terrain)' to 'PBTerrain.isSurfable?(terrain)' should fix these problems.
It fixed the initial activating surf animation issue. Now a new one has started, when I move in any direction in the water afterwards. I'll put an image below.
Look at the error. Please. "isSurfableTag?".
I tested my tutorial again on V 16.2, even on bridges. The working code:It fixed the initial activating surf animation issue. Now a new one has started, when I move in any direction in the water afterwards. I'll put an image below.
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
terrain=Kernel.pbFacingTerrainTag
notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
if !PBTerrain.isSurfable?(terrain) || !notCliff
Kernel.pbMessage(_INTL("No surfing here!"))
return false
end
return true
end
def useMoveSurf
$game_temp.in_menu=false
if !pbHiddenMoveAnimation(nil)
Kernel.pbMessage(_INTL("{1} used Surfboard!",$Trainer.name))
end
surfbgm=pbGetMetadata(0,MetadataSurfBGM)
pbCueBGM(surfbgm,0.5) if surfbgm
pbStartSurfing()
return true
end
I tested my tutorial again on V 16.2, even on bridges. The working code:
Code: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 terrain=Kernel.pbFacingTerrainTag notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction) if !PBTerrain.isSurfable?(terrain) || !notCliff Kernel.pbMessage(_INTL("No surfing here!")) return false end return true end def useMoveSurf $game_temp.in_menu=false if !pbHiddenMoveAnimation(nil) Kernel.pbMessage(_INTL("{1} used Surfboard!",$Trainer.name)) end surfbgm=pbGetMetadata(0,MetadataSurfBGM) pbCueBGM(surfbgm,0.5) if surfbgm pbStartSurfing() return true end
def Kernel.pbSurf
if $game_player.pbHasDependentEvents?
return false
end
if $DEBUG || movefinder=Kernel.pbCheckMove(:SURF)
if $DEBUG || $PokemonBag.pbQuantity(PBItems::SURFBOARD)>0
if Kernel.pbConfirmMessage(_INTL("The water is a deep blue, would you like to swim?"))
speciesname=!movefinder ? $Trainer.name : movefinder.name
Kernel.pbMessage(_INTL("You started swimming!",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 PBTerrain.isSurfable?(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
terrain=Kernel.pbFacingTerrainTag
notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
if !PBTerrain.isSurfable?(terrain) || !notCliff
Kernel.pbMessage(_INTL("No surfing here!"))
return false
end
return true
end
def useMoveSurf
$game_temp.in_menu=false
if !pbHiddenMoveAnimation(nil)
Kernel.pbMessage(_INTL("{1} used Surfboard!",$Trainer.name))
end
surfbgm=pbGetMetadata(0,MetadataSurfBGM)
pbCueBGM(surfbgm,0.5) if surfbgm
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
})
ItemHandlers::UseFromBag.add(:SURFBOARD,proc{|item|
next canUseMoveSurf? ? 2 : 0
})
ItemHandlers::UseInField.add(:SURFBOARD,proc{|item|
useMoveSurf if canUseMoveSurf?
})
def Kernel.pbSurf
if $game_player.pbHasDependentEvents?
return false
end
if $DEBUG || movefinder=Kernel.pbCheckMove(:SURF)
if $DEBUG || $PokemonBag.pbQuantity(PBItems::SURFBOARD)>0
if Kernel.pbConfirmMessage(_INTL("The water is a deep blue, would you like to swim?"))
speciesname=!movefinder ? $Trainer.name : movefinder.name
Kernel.pbMessage(_INTL("You started swimming!",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 PBTerrain.isSurfable?(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
terrain=Kernel.pbFacingTerrainTag
notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
if !PBTerrain.isSurfable?(terrain) || !notCliff
Kernel.pbMessage(_INTL("No surfing here!"))
return false
end
return true
end
def useMoveSurf
$game_temp.in_menu=false
if !pbHiddenMoveAnimation(nil)
Kernel.pbMessage(_INTL("{1} used Surfboard!",$Trainer.name))
end
surfbgm=pbGetMetadata(0,MetadataSurfBGM)
pbCueBGM(surfbgm,0.5) if surfbgm
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
})
ItemHandlers::UseFromBag.add(:SURFBOARD,proc{|item|
next canUseMoveSurf? ? 2 : 0
})
ItemHandlers::UseInField.add(:SURFBOARD,proc{|item|
useMoveSurf if canUseMoveSurf?
})