Change global variable when screen is off

Hi there,

I am working with KWGT and I have the following problem...

I need to change a global variable (text) to 0 when the screen turns off (so I can enable the visibility of an overlap group)
Is there any way to set gv(pn) to 0 whenever I turn off the screen?
I know that the function is $If(si(locked), gv(pn)=0)$ but I don't know where to write it...

Any help please?

let me explain it better...

When the widget starts i am giving to the the pn text global variable the value 0 and displays the following (overlap) screen

When i click the middle image at the center of the screen, its toggle (on touch) global switch pn to 6 and displays another overlap group with the layer function $if(gv(pv)=6,always,remove)$

When i click the first left bottom icon (house) it toggles (on touch) the global switch pn to 0 to display the (overlap) main screen with the layer function $if(gv(pv)=0,always,remove)$

If I am on an overlap group with pn value different than 0, how can make it 0 when the screen is off to return to the first (overlap) screen?

thank you for your time