• The Eevee Expo Game Jam #10 has concluded, congratulations to all participants! Now it's time for the judges to play through the games, and you can play along to vote who deserves the community choice spotlight.
    You can check out the submitted games here!
    Play through the games and provide some feedback to the devs while you're at it!
  • Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Random Pokémon selector

Resource Random Pokémon selector 1.0.1

ardicoozer

Cooltrainer
Member
Joined
Sep 29, 2020
Posts
171
I think that error would only show if you haven't installed the plugin correctly/compiled your plugins.
I already compile and place plugins in right place
and insert the command like on example
still got error like this :
Code:
Expand Collapse Copy
[2022-10-19 19:19:28 +0700]
[Pokémon Essentials version 20.1]
[v20.1 Hotfixes 1.0.5]

Script error in event 13 (coords 7,5), map 15 (Home)
Exception: NoMethodError
Message: undefined method `each_with_index' for "suggested":String

***Full script:
pkmn = pbChooseRandomPokemon(
blackList="suggested",
base_only=true,
use_gen=nil)
pbAddPokemon(pkmn, 20)

Backtrace:
[Random Pokemon Selector] 001_Random_Pokemon_Selector.rb:31:in `pbChooseRandomPokemon'
(eval):1:in `execute_script'
Interpreter:143:in `eval'
Interpreter:143:in `execute_script'
Interpreter_Commands:1112:in `command_355'
Interpreter_Commands:116:in `execute_command'
Interpreter:133:in `block in update'
Interpreter:90:in `loop'
Interpreter:90:in `update'
[Following Pokemon EX] Refresh.rb:255:in `update'

Edit : Nvm solved

I just insert the command like this :
Code:
Expand Collapse Copy
pkmn = pbChooseRandomPokemon
blackList = "suggested",
base_only = true
Code:
Expand Collapse Copy
pbAddPokemon(pkmn, 20)

Maybe in v20.1 need to update for the command, I'm just remove the
Code:
Expand Collapse Copy
()
and give a space between command and
Code:
Expand Collapse Copy
=
like on my example and the command worked...
 
Last edited:

ThatWelshOne_

Champion
Member
I already compile and place plugins in right place
and insert the command like on example
still got error like this :
Code:
Expand Collapse Copy
[2022-10-19 19:19:28 +0700]
[Pokémon Essentials version 20.1]
[v20.1 Hotfixes 1.0.5]

Script error in event 13 (coords 7,5), map 15 (Home)
Exception: NoMethodError
Message: undefined method `each_with_index' for "suggested":String

***Full script:
pkmn = pbChooseRandomPokemon(
blackList="suggested",
base_only=true,
use_gen=nil)
pbAddPokemon(pkmn, 20)

Backtrace:
[Random Pokemon Selector] 001_Random_Pokemon_Selector.rb:31:in `pbChooseRandomPokemon'
(eval):1:in `execute_script'
Interpreter:143:in `eval'
Interpreter:143:in `execute_script'
Interpreter_Commands:1112:in `command_355'
Interpreter_Commands:116:in `execute_command'
Interpreter:133:in `block in update'
Interpreter:90:in `loop'
Interpreter:90:in `update'
[Following Pokemon EX] Refresh.rb:255:in `update'

Edit : Nvm solved

I just insert the command like this :
Code:
Expand Collapse Copy
pkmn = pbChooseRandomPokemon
blackList = "suggested",
base_only = true
Code:
Expand Collapse Copy
pbAddPokemon(pkmn, 20)

Maybe in v20.1 need to update for the command, I'm just remove the
Code:
Expand Collapse Copy
()
and give a space between command and
Code:
Expand Collapse Copy
=
like on my example and the command worked...
The code in your earlier message works fine for me, so that's an error of some kind on your end.

This second error is because you can't skip arguments in Ruby, as far as I know. So doing:
Ruby:
Expand Collapse Copy
pkmn = pbChooseRandomPokemon(
blackList="suggested",
base_only=true,
use_gen=nil)
Doesn't work because you've skipped the whiteList argument (Ruby is trying to interpret what you've given it using blackList as whiteList).

Then, in your "fix", removing the parentheses makes it so that you're effectively only doing:
Ruby:
Expand Collapse Copy
pkmn = pbChooseRandomPokemon
Which is just the script with all default arguments.
If you want the suggested blacklist, then you need to do:
Ruby:
Expand Collapse Copy
pkmn = pbChooseRandomPokemon(
whiteList=nil,
blackList="suggested"
)
 

ardicoozer

Cooltrainer
Member
Joined
Sep 29, 2020
Posts
171
Good solutions
I'll try it
Thanks for help

I almost forgot,
How to make a random pokemon be a shiny?
The code in your earlier message works fine for me, so that's an error of some kind on your end.

This second error is because you can't skip arguments in Ruby, as far as I know. So doing:
Ruby:
Expand Collapse Copy
pkmn = pbChooseRandomPokemon(
blackList="suggested",
base_only=true,
use_gen=nil)
Doesn't work because you've skipped the whiteList argument (Ruby is trying to interpret what you've given it using blackList as whiteList).

Then, in your "fix", removing the parentheses makes it so that you're effectively only doing:
Ruby:
Expand Collapse Copy
pkmn = pbChooseRandomPokemon
Which is just the script with all default arguments.
If you want the suggested blacklist, then you need to do:
Ruby:
Expand Collapse Copy
pkmn = pbChooseRandomPokemon(
whiteList=nil,
blackList="suggested"
)
 
Last edited:

tyssonpark

Novice
Member
Joined
Nov 13, 2021
Posts
23
=================

[2023-05-07 18:24:18 -0300]
[Pokémon Essentials version 20.1]
[v20.1 Hotfixes 1.0.7]

Script error in event 16 (coords 3,5), map 7 (Centro pokemon viridian)
Exception: SyntaxError
Message: (eval):7: unterminated string meets end of file
pbAddPokemon(pkmn, 100)
^
(eval):7: syntax error, unexpected end-of-input, expecting ')'
pbAddPokemon(pkmn, 100)
^


***Full script:
pkmn = pbChooseRandomPokemon(
whiteList=nil,
blackList="nil,
addList=nil,
base_only=false,
use_gen=[8])
pbAddPokemon(pkmn, 100)

can you help me? (how long! XD)
 

ThatWelshOne_

Champion
Member
=================

[2023-05-07 18:24:18 -0300]
[Pokémon Essentials version 20.1]
[v20.1 Hotfixes 1.0.7]

Script error in event 16 (coords 3,5), map 7 (Centro pokemon viridian)
Exception: SyntaxError
Message: (eval):7: unterminated string meets end of file
pbAddPokemon(pkmn, 100)
^
(eval):7: syntax error, unexpected end-of-input, expecting ')'
pbAddPokemon(pkmn, 100)
^


***Full script:
pkmn = pbChooseRandomPokemon(
whiteList=nil,
blackList="nil,
addList=nil,
base_only=false,
use_gen=[8])
pbAddPokemon(pkmn, 100)

can you help me? (how long! XD)
You have a stray quote on your blackList line.
 

ThatWelshOne_

Champion
Member
TY!
Is there any way I can add generation 9 in the script? and maybe type of pokemons?
Assuming you have the Gen 9 project installed, you would just need to change the use_gen option to use_gen=[8, 9] to include Gen 8 and 9 only. Bearing in mind this is only the new species from Gen 8 and 9. If you want Bulbasaur to Mew as well, you'd need use_gen=[1, 8, 9].

For your second question, you can do something like this to pre-generate a white list of Pokémon of a certain type:
Ruby:
Expand Collapse Copy
white_list = []
GameData::Species.each { |s| white_list.push(s.id) if s.types.include?(:ICE) || s.types.include?(:DRAGON) }
white_list.uniq!

pkmn = pbChooseRandomPokemon(
whiteList=white_list,
blackList="nil,
addList=nil,
base_only=false,
use_gen=nil)
To only include Ice- and Dragon-types (from any generation). I thought include? could accept an array like s.types.include?([:ICE, :DRAGON]), but it turns out I'm rustier than I thought.
 

Phye

Moon Guardian
Member
Joined
Oct 25, 2022
Posts
32
Is there a way to have a larger pool of whitelisted pokemon? Because sometimes you don't feel like banning all but 20 pokemon just to randomize between 20 pokemon!
 

Phye

Moon Guardian
Member
Joined
Oct 25, 2022
Posts
32
Yes, but there is a limit to the script window on how many pokemon you can fit there even with extend text. I'm not as cunning to fit multiple objects in an array that is pulled from somewhere else.
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
663
Try putting multiple scripts one after the other without closing the brackets until the last one.
Something like that.
Script 1: whitelist = [:BULBASAUR,
Script 2: :IVYSAUR,
Script 3: :VENUSAUR]
This is just an exaggerated example, but putting scripts one after the other without anything in the middle makes them work as a single script so you can try and see if it works.
 

Drqiu

Novice
Member
Joined
Jun 6, 2023
Posts
24
Hi, this plugin is great! May I ask what should I do if I want players to possibly get randomised region form Pokémon? Will regional form Pokémon be generated without whitelisting enabled by default? For example, if I set use_gen=[7], might there be :RATTATA_1 generated? I tried the following code and it is possible. Is there any other way to do this?

whitelist=[:RATTATA_1]
pkmn = pbChooseRandomPokemon(
whiteList=whitelist,
blackList=nil,
addList=nil,
base_only=nil,
use_gen=nil)
pbAddPokemon(pkmn, 5)

I want :RATTATA_1 and use_gen=[1] to be implemented at the same time, is it possible?
 

grogro

Cooltrainer
Member
Joined
Mar 6, 2021
Posts
120
The problem is that some species have 1 million cosmetic or specific forms so it could become weird. But nothing prevents you from editing the generated pokemon. I'm personaly using a pbrandomform function that I call after generating the pokemon. It's not perfect but at least they can appear. Here it is:

def pbRandomform(pkmn)
forms = [0]
namelist=["Alolan","Galarian","Female","10%","Cloak","Kyurem",
"Size","Unbound","Style","Midnight","Dusk","Low Key","Rider"]
GameData::Species.each do |sp|
next if sp.species != pkmn.species
for j in namelist
if sp.form_name!=nil
if sp.form_name.include? j
forms.push(sp.form)
end
end
end
end
form = forms.sample
pkmn.form = form
end
 
Back
Top