Probably the easiest way would be to use the Lua SwitchScript command, i.e. have an collectable entity as a trigger then have it switch scripts to the compass.lua script when you pick it up.
I haven't tested this but I assume when you switch scripts GG will run the init script first before running main for the first time.
I have discovered btw that if you repeatedly test a level then escape back to the editor and test it again the init script doesn't get run and the previous global variables do not get reset, I have been putting protective code in my scripts to detect this occurrence but it is something to take account of as it can result is some really strange behaviour.
If you need to turn the compass on and off by a key stroke then you will need to add some code to push the sprites off screen and put them back.
Been there, done that, got all the T-Shirts!