Disable during Menu

So due to work, life and many other reasons I'd abandoned my project back towards the end of 2013 and haven't picked it back up, until now... I intended to come at it with fresh perspective and fresh plans and though a lot of basic coding I still have down, it is likely due to lack of sleep but something that I know should be a simple fix is drawing blanks for me so I thought I'd post it here as I'm going to be working most of the week and won't have as much time to figure it out myself as I dive back into scripting.

So on one of my old scripts I have this snippet of code:

class Game_Interpreter def SetTimer(map_id,event_id,time) event_id = @event_id if event_id == 0 map_id = $game_map.map_id if map_id == 0 $game_system.Timer[[map_id,event_id]] = $game_system.playtime + time endendIt's a simple process that sets up a timer that runs globally for a specific event and map based on second intervals.

However, I noticed that as it is a global timer it even runs while within the menus, which in my eyes is a "paused state". This is troublesome because my game has mechanics that means that they must look after stats which deplete over time and they can craft items which increases those stats but they take time to make which is where the global timers come in, you can go away and come back once it is done. Now as it currently stands... the player can simple enter the menu and leave it paused for their stats to stop decreasing and then unpause to gain the item once it would of been done and repeat, exploiting the game to get many stat increase items without losing much stats at all.

The fix for this problem would be to encompass this line:

$game_system.Timer[[map_id,event_id]] = $game_system.playtime + timeand embed it in an if statement that would check if the menu is in fact open and if it is, do nothing, if it isn't then do this line as normal. Now I am aware of the issues of Ruby being a language that must pull results so if I can make a statement that is inverted to check if the menu is closed (and any other custom menus I have added in) then it performs this line. Then when the menu is open, it would not process this line and the timer would disable itself until the menu is closed again.

At least that is my theory, if not then I will find a work around as I always do but I just figured as I have a lot of work this week, someone would be kind enough just to save me a little time and point me in the right direction of a few lines of code to plug in that would perform the task I am asking.

Much appreciated in advance.

Original thread: https://forums.rpgmakerweb.com/threads/disable-during-menu.37861/