Using a function it's clearly defined what's the input and what's the output.
It's possible to `yield` the current progress.
My notion is: If the script wants some data from the engine it calls a function in `Engine`. If the script wants to send some data to the engine it should use `yield` or `return`.
The values/properties `g_MapSettings`, `Engine.SetProgress` and `Engine.ExportMap` could be removed in a future version of 0 A.D., which would make the C++ side simpler.
TODO:
- Use errors which are `instanceof Error`.
- `g_MapSettings`, `Engine.SetProgress` and `Engine.ExportMap` should be removed before the generator is called. So they are not useable inside the generator.
Refs: #4964