Picture Error

Hey guys, I tried searching this forum for the answer and couldn't find one.


So, in my game I'm trying to create a cool fog (or smoke in my case) effect. I used This nifty tutorial for it. Everything works fine for the most part when I enter the map with the fog it looks amazing. However, when I left, the fog persisted. Not something I wanted. Following the advice in the thread I created an "Erase Picture" event on the next maps to get rid of the fog. That worked too, the fog was gone and the screen was back to normal.


Now, when I go back into the fog map, I get the following error:


"Script 'sprite_Picture' line 54: NoMethodError occurred.


undefined method 'width' for nil:NilClass"


Neither the mentioned thread, nor any other seem to answer have the answer, I was wondering if anyone has any ideas.


I apologize if this has already been answered, but I checked like maybe four pages of search results and came up empty.


Below are pictures of both the error, and the events in question. Let me know if you need anything else.

Error4.png

Error.png

Error2.png

Error3.png
Because your fog event is trying to move a picture that no longer exists - you erased it on the other map, and the event page that creates the fog on this map has already been disabled by the self-switch, the move page starts directly.
Wow, thank you! I didn't expect a reply so quickly.


Okay, I get why I'm getting the error now, so how can I get the fog to disappear on the next map, and reappear when I go back?


Or, at the very least, remain off when I reenter.
Every map needs an event to appear or vanish the fog depending on its status.


Which basically means you can't switch off the page showing the picture.


One solution would be to make two events with the show fog erasing itself after the show command, but that still might cause timing errors if the move fog would happen before the create event.


It is a lot better to assign a general switch for controlling the fog, not a self-switch, and then keep everything on one map as well. That way you don't have to mess with the other maps.


1) make a switch "fog moving"


2) make a common event with the move pictures command on parallel, conditioned to that switch.


3) on the map that has the fog, make a parallel process with show picture(fog), control switch fog moving ON and erase event


4) on the map with that fog, edit ALL transfers that go to a different map to control off the fog moving switch and erase picture before the transfer command.


No need to go to other maps with events there, which will reduce the bughunting area in case of problems as well.
Oh my glob that worked! Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/picture-error.61359/