Tried this real quickly, but it does not appear to be working either... I'll have to due more thorough testing and recheck my code in the morning
It should work, I do similar timing tricks all the time. There MAY be a problem with the timing though, maybe the engine lets the gamemode block run for a couple of frames AFTER the onActivate block has run, but before the container is fully opened. To ensure that this is not a problem you could expand the code a bit. Use da mage's code, but add a small menumode block as well, and change the check in the gamemode block. This way you are 100% sure that the gamemode block doesn't get to run until the container has been actiavated, opened and closed.
begin menumode if chestopened == 1 set chestopened to 2 endifend
begin gamemodeif chestopened == 2[do stuff]set chestopened to 0endifend
Also, in the wiki for startquest "Avoid calling this function to start a quest which is already running. If there is a script attached to the quest, any variables will be reset to 0 when the saved game is reloaded." Quest variables are deleted when you reload the game? That would mess up my script if it is true, though would make sense. Any way around that if this is the case?
They are only deleted if you have called Startquest on the quest before the last save. So just don't call Startquest more than once (All my gametweak scripts are enabled from the start of the game, and I never call startquest on them), and you avoid the problem.