Make more use of DefineConsoleMethod

Resubmission of #887 with some fixes.
mmmmm welcome to the fucking world of TS ids... -1 or 0 for invalid?