• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • Reminder: AI-generated content is not allowed on the forums per the Rules and Regulations. Please contact us if you have any questions!
[v17+] Roaming Icon on Map

Resource [v17+] Roaming Icon on Map 1.1.3

@-FL- Hello, I installed this script according to the instructions in the Ruby source file, and am getting this error upon opening the region map via the PokeGear:
Ruby:
Expand Collapse Copy
undefined method `[]' for nil:NilClass
The error tells me it's pointing to the usage of draw_roaming_position(mapindex), which I find odd.
Any reason why this isn't working?
Essentials Version 21.1
 
@-FL- Hello, I installed this script according to the instructions in the Ruby source file, and am getting this error upon opening the region map via the PokeGear:
Ruby:
Expand Collapse Copy
undefined method `[]' for nil:NilClass
The error tells me it's pointing to the usage of draw_roaming_position(mapindex), which I find odd.
Any reason why this isn't working?
Essentials Version 21.1
I tested right here in v21.1 and I can't reproduce this bug. Recheck the instructions (images places and line position), if issue remains, test in a vanilla Essentials. If the error doesn't happen, maybe some plugin is affecting it.
 
I tested right here in v21.1 and I can't reproduce this bug. Recheck the instructions (images places and line position), if issue remains, test in a vanilla Essentials. If the error doesn't happen, maybe some plugin is affecting it.
Hey, sorry for the late reply! I tested in Vanilla Essentials and it does work, as expected.
I tested in a backup copy of my game, which does have plugins, and it worked right off the bat.
I tested it now in the current copy of the game, which is about a month newer with no additional plugins, and it does work on a NEW save file/new game. It does NOT work if I continue with the current save file I am using to debug/playtest

The entire error is the following:

Code:
Expand Collapse Copy
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Exception: NoMethodError
Message: undefined method `[]' for nil:NilClass

Backtrace:
UI_RoamingPokes:34:in `block in draw_roaming_position'
UI_RoamingPokes:33:in `each'
UI_RoamingPokes:33:in `draw_roaming_position'
UI_RegionMap:133:in `pbStartScene'
UI_RegionMap:342:in `pbStartScreen'
UI_Pokegear:168:in `block (2 levels) in <main>'
MessageConfig:575:in `pbFadeOutIn'
UI_Pokegear:165:in `block in <main>'
UI_Pokegear:151:in `block in pbStartScreen'
UI_Pokegear:145:in `loop'

Any clue at all as to why that's happening? It's not a huge issue but it does make debugging a tad more tedious.
 
- reply -
well, it's always recommended to not get attached to your save files, and it's always recommended to start new saves for changes or additions to make effects on the game. you don't need the same save for everything.
also, the game won't update its scripts already loaded on the save, so starning a new one forces it to load any changed you have made.
 
well, it's always recommended to not get attached to your save files, and it's always recommended to start new saves for changes or additions to make effects on the game. you don't need the same save for everything.
also, the game won't update its scripts already loaded on the save, so starning a new one forces it to load any changed you have made.
I agree starting a new save is usually the way to go when dealing with adding new plugins! I just find it so bizarre that it works on an older version of my game, loading the exact same save file, but won't work on the newer version with said save file. This is the only plugin/script change I've done that has not liked continuing with the old save file.
 
Hey, sorry for the late reply! I tested in Vanilla Essentials and it does work, as expected.
I tested in a backup copy of my game, which does have plugins, and it worked right off the bat.
I tested it now in the current copy of the game, which is about a month newer with no additional plugins, and it does work on a NEW save file/new game. It does NOT work if I continue with the current save file I am using to debug/playtest

The entire error is the following:

Code:
Expand Collapse Copy
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Exception: NoMethodError
Message: undefined method `[]' for nil:NilClass

Backtrace:
UI_RoamingPokes:34:in `block in draw_roaming_position'
UI_RoamingPokes:33:in `each'
UI_RoamingPokes:33:in `draw_roaming_position'
UI_RegionMap:133:in `pbStartScene'
UI_RegionMap:342:in `pbStartScreen'
UI_Pokegear:168:in `block (2 levels) in <main>'
MessageConfig:575:in `pbFadeOutIn'
UI_Pokegear:165:in `block in <main>'
UI_Pokegear:151:in `block in pbStartScreen'
UI_Pokegear:145:in `loop'

Any clue at all as to why that's happening? It's not a huge issue but it does make debugging a tad more tedious.
This gonna be a little tricky to solve since I can't replicate the issue here and I don't know what is causing it, so I can't do several tests.

Try changing code

Code:
Expand Collapse Copy
      active = $game_switches[Settings::ROAMING_SPECIES[roam_pos[0]][2]] && (
        $PokemonGlobal.roamPokemon.size <= roam_pos[0] ||
        $PokemonGlobal.roamPokemon[roam_pos[0]]!=true
      )

to

Code:
Expand Collapse Copy
      active = roam_pos && roam_pos[0] && Settings::ROAMING_SPECIES[roam_pos[0]][2] && $game_switches[Settings::ROAMING_SPECIES[roam_pos[0]][2]] && (
        $PokemonGlobal.roamPokemon.size <= roam_pos[0] ||
        $PokemonGlobal.roamPokemon[roam_pos[0]]!=true
      )

well, it's always recommended to not get attached to your save files, and it's always recommended to start new saves for changes or additions to make effects on the game. you don't need the same save for everything.
Not by me.

This is a trend by scripters, but most of save issues are very easy to fix.

Barring some special cases where supporting old saves are very trickier, I support old saves and I even took some decisions to keep save compatibility.

Same with supporting older Essentials.
 
This gonna be a little tricky to solve since I can't replicate the issue here and I don't know what is causing it, so I can't do several tests.

Try changing code

Code:
Expand Collapse Copy
      active = $game_switches[Settings::ROAMING_SPECIES[roam_pos[0]][2]] && (
        $PokemonGlobal.roamPokemon.size <= roam_pos[0] ||
        $PokemonGlobal.roamPokemon[roam_pos[0]]!=true
      )

to

Code:
Expand Collapse Copy
      active = roam_pos && roam_pos[0] && Settings::ROAMING_SPECIES[roam_pos[0]][2] && $game_switches[Settings::ROAMING_SPECIES[roam_pos[0]][2]] && (
        $PokemonGlobal.roamPokemon.size <= roam_pos[0] ||
        $PokemonGlobal.roamPokemon[roam_pos[0]]!=true
      )


Not by me.

This is a trend by scripters, but most of save issues are very easy to fix.

Barring some special cases where supporting old saves are very trickier, I support old saves and I even took some decisions to keep save compatibility.

Same with supporting older Essentials.
Thank you for the reply! Unfortunately this did not work. I receive the same error:

Ruby:
Expand Collapse Copy
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Exception: NoMethodError
Message: undefined method `[]' for nil:NilClass

Backtrace:
UI_RoamingPokes:34:in `block in draw_roaming_position'
UI_RoamingPokes:33:in `each'
UI_RoamingPokes:33:in `draw_roaming_position'
UI_RegionMap:133:in `pbStartScene'
UI_RegionMap:342:in `pbStartScreen'
UI_Pokegear:168:in `block (2 levels) in <main>'
MessageConfig:575:in `pbFadeOutIn'
UI_Pokegear:165:in `block in <main>'
UI_Pokegear:151:in `block in pbStartScreen'
UI_Pokegear:145:in `loop'
 
Thank you for the reply! Unfortunately this did not work. I receive the same error:

Ruby:
Expand Collapse Copy
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Exception: NoMethodError
Message: undefined method `[]' for nil:NilClass

Backtrace:
UI_RoamingPokes:34:in `block in draw_roaming_position'
UI_RoamingPokes:33:in `each'
UI_RoamingPokes:33:in `draw_roaming_position'
UI_RegionMap:133:in `pbStartScene'
UI_RegionMap:342:in `pbStartScreen'
UI_Pokegear:168:in `block (2 levels) in <main>'
MessageConfig:575:in `pbFadeOutIn'
UI_Pokegear:165:in `block in <main>'
UI_Pokegear:151:in `block in pbStartScreen'
UI_Pokegear:145:in `loop'
You didn't change the script (like removing the comments or PluginManager.register), right? Asking because changing this also changes the line count..

Change the previous code to
Code:
Expand Collapse Copy
active = roam_pos != nil
active &&= roam_pos[0]
active &&= Settings::ROAMING_SPECIES[roam_pos[0]][2]
active &&= $game_switches[Settings::ROAMING_SPECIES[roam_pos[0]][2]]
active &&= $PokemonGlobal.roamPokemon
active &&= $PokemonGlobal.roamPokemon.size <= roam_pos[0] || $PokemonGlobal.roamPokemon[roam_pos[0]]!=true
This gonna work or the error line should change.
 
You didn't change the script (like removing the comments or PluginManager.register), right? Asking because changing this also changes the line count..

Change the previous code to
Code:
Expand Collapse Copy
active = roam_pos != nil
active &&= roam_pos[0]
active &&= Settings::ROAMING_SPECIES[roam_pos[0]][2]
active &&= $game_switches[Settings::ROAMING_SPECIES[roam_pos[0]][2]]
active &&= $PokemonGlobal.roamPokemon
active &&= $PokemonGlobal.roamPokemon.size <= roam_pos[0] || $PokemonGlobal.roamPokemon[roam_pos[0]]!=true
This gonna work or the error line should change.
Hello! I have not changed any code or comments - everything is implemented as intended.
This did not work, opening the TownMap still gives the same errors; however the error line(s) did change. Take a look:

Ruby:
Expand Collapse Copy
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Exception: NoMethodError
Message: undefined method `[]' for nil:NilClass

Backtrace:
UI_RoamingPokes:36:in `block in draw_roaming_position'
UI_RoamingPokes:33:in `each'
UI_RoamingPokes:33:in `draw_roaming_position'
UI_RegionMap:133:in `pbStartScene'
UI_RegionMap:342:in `pbStartScreen'
UI_Pokegear:168:in `block (2 levels) in <main>'
MessageConfig:575:in `pbFadeOutIn'
UI_Pokegear:165:in `block in <main>'
UI_Pokegear:151:in `block in pbStartScreen'
UI_Pokegear:145:in `loop'

The first error now points to line 36 rather than 34. Line 36 in the code is currently the following:
Code:
Expand Collapse Copy
active &&= Settings::ROAMING_SPECIES[roam_pos[0]][2]

Commenting out that line of code causes line 37 to error instead:
Code:
Expand Collapse Copy
active &&= $game_switches[Settings::ROAMING_SPECIES[roam_pos[0]][2]]

Commenting out both lines 36 and 37 causes the program to no longer crash, however the Roaming Pokemon are not displayed on the TownMap.
Looks like something funky with the above two lines is happening.
 
Last edited:
Hello! I have not changed any code or comments - everything is implemented as intended.
This did not work, opening the TownMap still gives the same errors; however the error line(s) did change. Take a look:

Ruby:
Expand Collapse Copy
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Exception: NoMethodError
Message: undefined method `[]' for nil:NilClass

Backtrace:
UI_RoamingPokes:36:in `block in draw_roaming_position'
UI_RoamingPokes:33:in `each'
UI_RoamingPokes:33:in `draw_roaming_position'
UI_RegionMap:133:in `pbStartScene'
UI_RegionMap:342:in `pbStartScreen'
UI_Pokegear:168:in `block (2 levels) in <main>'
MessageConfig:575:in `pbFadeOutIn'
UI_Pokegear:165:in `block in <main>'
UI_Pokegear:151:in `block in pbStartScreen'
UI_Pokegear:145:in `loop'

The first error now points to line 36 rather than 34. Line 36 in the code is currently the following:
Code:
Expand Collapse Copy
active &&= Settings::ROAMING_SPECIES[roam_pos[0]][2]

Commenting out that line of code causes line 37 to error instead:
Code:
Expand Collapse Copy
active &&= $game_switches[Settings::ROAMING_SPECIES[roam_pos[0]][2]]

Commenting out both lines 36 and 37 causes the program to no longer crash, however the Roaming Pokemon are not displayed on the TownMap.
Looks like something funky with the above two lines is happening.
The value is nil, just trying to find the value and skipping it's check.

Change the code block again to:
Code:
Expand Collapse Copy
active = roam_pos != nil
active &&= roam_pos[0]
active &&= Settings::ROAMING_SPECIES
active &&= Settings::ROAMING_SPECIES[roam_pos[0]]
active &&= Settings::ROAMING_SPECIES[roam_pos[0]][2]
active &&= $game_switches[Settings::ROAMING_SPECIES[roam_pos[0]][2]]
active &&= $PokemonGlobal.roamPokemon
active &&= $PokemonGlobal.roamPokemon.size <= roam_pos[0] || $PokemonGlobal.roamPokemon[roam_pos[0]]!=true
 
The value is nil, just trying to find the value and skipping it's check.

Change the code block again to:
Code:
Expand Collapse Copy
active = roam_pos != nil
active &&= roam_pos[0]
active &&= Settings::ROAMING_SPECIES
active &&= Settings::ROAMING_SPECIES[roam_pos[0]]
active &&= Settings::ROAMING_SPECIES[roam_pos[0]][2]
active &&= $game_switches[Settings::ROAMING_SPECIES[roam_pos[0]][2]]
active &&= $PokemonGlobal.roamPokemon
active &&= $PokemonGlobal.roamPokemon.size <= roam_pos[0] || $PokemonGlobal.roamPokemon[roam_pos[0]]!=true
Progress! The game no longer crashes when opening the Region Map.
However, the sprites do not appear on the map. (Yes, I have the right sprites for the Pokemon in the correct folders, and yes I have the correct game switch on)
Additionally, I also believe the Roaming encounters simply aren't spawning - In my settings for testing purposes I have roaming encounters locked to two connected routes.

I tested 100 encounters on both routes and did not manage to spawn either roaming Pokemon.

I tested the new code on a new save file, and the encounters did spawn and did appear on the Region Map.
 
Back
Top