Reimplement game_type and autodetection of script_style
Halfway refactor Tpwork (and also touch Tpstate)

- Break stuff out into functions (death to KLOC functions!)
- Untabify
- Consistent indentation
- Break some long lines
- Struggle vainly
Also set MOD_FOLDER when automatically reinstalling mods