- 10
- Posts
- 11
- Years
- Seen Apr 23, 2022
I was writing a script to generate custom event encounter (where you can spawn any species with any ability, item or move combination). It works when I pass all four moves but I can't get it to work when I want the Pokemon to learn only 1 move (3 should be blank).
The event is triggering this
The error
According to wiki, 0 is supposed to be the ID for no move
The script
The event is triggering this
Code:
pbCustomWildBattle({'species' => :SNORLAX, 'ability' => :PRESSURE, 'level' => 35, 'item' => :AIRBALLOON})
The error
Code:
Message: Unknown ID 0.
The script
Code:
species = GameData::Species.get(hash.fetch('species', :BULBASAUR)).id
level = hash.fetch('level', 20)
ability = hash.fetch('ability', :SPEEDBOOST)
item = hash.fetch('item', :LEFTOVERS)
# moves is an array containing a list of moves I want it to spawn with
moves = hash.fetch('moves', [])
genwildpoke = Pokemon.new(species,level)
# Customize the generated pokemon
genwildpoke.ability = ability
genwildpoke.item = item
for i in 0..3
# if a custom move was not mentioned
if moves[i].nil?
# and if this is the first move slot
if i < 1
# give this pokemon metronome as the first move [COLOR="Cyan"]THIS WORKS FINE[/COLOR]
genwildpoke.moves[i] = Pokemon::Move.new(:METRONOME)
else
# otherwise give all other slots a "no move" [URL="https://essentialsdocs.fandom.com/wiki/Moves"]as defined here[/URL] [COLOR="Red"]THIS DOES NOT WORK[/COLOR]
genwildpoke.moves[i] = Pokemon::Move.new(0)
end
else
# otherwise give it whatever moves i want in that slot [COLOR="Cyan"]THIS WORKS FINE[/COLOR]
genwildpoke.moves[i] = Pokemon::Move.new(moves[i])
end
end
Last edited: