Bad Sector
Arcane
- Joined
- Mar 25, 2012
- Messages
- 2,334
It would be more reasonable to test for things like "actual gameplay has been stuck for X frames now" to decide whether you're dealing with an infinite loop or not,
This only works if the scripting language works in parallel with the rest of the game engine but it is a very uncommon approach, most game engines have the scripting language work in sync with the rest of the engine - e.g. the engine makes a call to script foo, script foo executes and finishes, engine resumes execution after that (often it is really just like a function call).
rather than fucking with the guy trying to initialize some data in a loop.
Generally speaking if this is something the guy is supposed to do, the scripting language should allow it, but in general scripting languages in games are meant just for that: scripting the game's behavior, not writing the behavior. Or to put it another way, you use the scripting language to tell the engine what to do, but not how to do it.
FWIW IMO the "best" approach would be to use time when checking for infinite loops: if the loop takes something like 5 seconds (which should be *WAY* more than enough - loops in scripts shouldn't even take a second), then it should trigger some failsafe. But i put "best" in quotes because at that point the game state would be broken anyway and the best you can do is show a message to the user to restart the game. Ideally the scripting language should provide mechanisms (e.g. enumerators) so that most such loops should not be needed in the first place (and chances are they'll be much faster than anything a script could do).