• 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.
  • The Eevee Expo Game Jam has concluded! 🎉 Head on over to the game jam forum to play through the games.
    Don't forget to come back September 21st to vote for your favorites!
  • Reminder: AI-generated content is not allowed on the forums per the Rules and Regulations. Please contact us if you have any questions!

fixing NoMethodError in Pokemon Essentials' Pokegear phone calls

Molly

Rookie
Member
Joined
Jan 14, 2024
Posts
8
So I figured out reason my game crashes in building is because Pokegear phone feature which I only notice until now and I can't figure it
the error code:

[Pokémon Essentials version 21.1]

Exception: NoMethodError
Message: undefined method `has_flag?' for nil:NilClass

Backtrace:
Item_Phone:323:in `can_make?'
Item_Phone:372:in `make_incoming'
Item_Phone:558:in `block in <main>'
Event_Handlers:89:in `block in trigger'
Event_Handlers:89:in `each_value'
Event_Handlers:89:in `trigger'
Event_HandlerCollections:63:in `trigger'
Scene_Map:162:in `updateSpritesets'
Scene_Map:176:in `update'
Scene_Map:238:in `block in main'

the script in Item_Phone that causing game to crash:
def can_make?
return false if $game_map.metadata.has_flag?("NoPhoneSignal")
return true
end

it only happen at indoor building such as warehouse and mansion, and yeah i didn't register any trainers on pokegear so i think it try to recall nonexistent trainer / recall in indoor that having "NoPhoneSignal" which i can't find it on metadata, hence the error
how to fix it? or how to disable pokegear random call all together as default without you needing to disable it manually?
 
I registered for an account here for the sole purpose of responding to this forum post, for you and anyone else who may stumble upon this in the future.

I had the same error pop up for me, and it happened whether I was inside or outside. And this was just me messing with Professor Oak, copying the event from the example map and pasting onto a new map. Everything worked perfectly fine when I went to the example map, but got errors when I went to the map I created. I spent a few days days searching online for help and trying on Discord. Of course nobody had the answer. But finally I got it working! So maybe it'll help you, too.

I don't understand the system well enough to really get why the new map required this but the example map doesn't. But BEFORE the Phone.add script call, I added a Show Text line and just had Oak say "All righty, here is my phone number." (You can put any text you want tbh.) After that, I tested several times and have yet to run into that error again.

The theory is that it's giving the game enough time to finish initializing everything before the Phone.add happens.
 
This problem is caused when the map the NPC is associated with doesn't have metadata.

To break this down further, if you are calling the following script:
Ruby:
Expand Collapse Copy
Phone.add(1, "Professor Oak", 100)

Then in your map_metadata.txt PBS file, you'll need something like the following:
Ruby:
Expand Collapse Copy
#-------------------------------
[100]   # Pokémon Lab
Name = Pokémon Lab

(P.S. You don't need a text line before the script call)
 
Back
Top