menu returns in which "state" the game is/which menu is open:
0 - normal game ( no menu open )
1 - character page/menu
2 - inventory
3 - diary/journal
20 - the list of buildings ( where you can choose what you want to build )
21 - messagebox (msg)
23 - exchange with animals/ buildings
24 - map
25 - cracklock
26 - dialogue
100 - sequence (seqstart)
300 - top-view in which you can choose where your building should be built
301 - (selectplace)
So you can check what the player is currently doing/looking at.
1
2
3
4
2
3
4
if (menu()==0){ // if no menu is open 	// do something ... 	// ... }
@Bloodshot
please specify the problem.
What is not working ?