Actually the messageboxes are there purely to show it doing something while testing I have no intention of them spamming and slowing the game down.
Spamming them doesn't slow the game down, but if more than 2 or 3 are shown at a time (in a single frame), the game can crash. That interacts badly with various menus, as well.
The return is just a nasty habit I developed many moons ago i.e. pop! push! (old Amiga coder Im afraid)
Morrowind scripts are, for most purposes, parallel and linear. They run from the beginning, test each conditional, and continue until they reach a return or the end of the script. That repeats the next frame. Scripts run one after another, but the order has not been proven to be reliable, so I wouldn't recommend relying on that.
Funny enough there is a mod that locks/ unlocks doors depending on the time of day and that also crashes my game (I just discovered) - Starting to wonder if its some other mod that is bugging this function although Beth really have some odd requirements for some of their commands.
GameHour isn't a function and simply testing the variable is one of the few things not likely to cause a crash. Testing your other mods, though, would be a good idea.
Maybe the answer is obvious but I cannot figure it out - what determines location variable in this script?
Good catch, I actually forgot to set that. It should be handled in the various state blocks near PositionCell.