I wouldn't use a function to return a custom object either, since function's cant be made global by anyone but Stefan. Using my method, it creates objects with the typical global name that can be used anywhere without the need for joining classes to access the functions and such.
PHP Code:
function onActionPlayerOnline() {
MudControl.player_Inverness = new TXMudPlayer("MudPlayer_Inverness");
}
Looks nicer like that too.