Help identifying correct Script call

Im making an event that checks if X picture is displayed, if yes then it runs event, that works great, the issue is in the else statement.
What would be the correct script to use to check if picture X has been erased or is no longer shown?
I believe this will work (in a conditional branch script call):

JavaScript:
$gameScreen.picture(3).name()

From what I can tell, that should return true if picture 3 is currently displayed.

(If you want to be a little more pedantic, you can add two exclamation marks to the beginning, or != '' to the end - just one of those, not both.)
so then if picture 3 is no longer shown it will return false correct?
It should return false if picture 3 is not currently shown, yes.
okay let me do a quick test. thanks
$gameScreen.picture(3).name()
Using that will return true in an if statement, but also will return an error on the else statement(if picture is not on the screen -erased-) Cannot read property 'name' of null
1593993319229.png


The correct is using only this:
JavaScript:
$gameScreen.picture(3)
1593993404048.png

Because if it is erased, the code ($gameScreen.picture(3)) will return null.
ooohhhh okay, i kinda ended up using something completely different to make the event work, but now i've learned a little more, thanks.
Yeah, I was a little uncertain about whether erased pictures still exist (just with no picture) or are destroyed entirely.
If you want to execute something one time every time the Picture gets shown or deleted, you could do this:
(I copy pasted the Eventcode as Text)
Code:
◆If:Script:$gameScreen.picture(3)
  ◆If:Switch19 is OFF
    ◆Control Switches:#0019 Switch19 = ON
    ◆Text:None, Window, Bottom
    :    :Some Event somewhere made that Picture 3 is shown.
    ◆
  :End
  ◆
:Else
  ◆If:Switch19 is ON
    ◆Control Switches:#0019 Switch19 = OFF
    ◆Text:None, Window, Bottom
    :    :Some Event somewhere made that Picture 3 got Erased.
    ◆
  :End
  ◆
:End
Thanks for that Info. I actually found a very usual edit of a plugin that made the whole process way more simply and made it touch or mouse click like I wanted.
Since yeps pic common event wouldn't work in this case and galvs screen buttons didn't play well with umapi.

Original thread: https://forums.rpgmakerweb.com/threads/help-identifying-correct-script-call.123669/