biggest hurdle to train factory is an implementation of spline meshes for the train tracks and a ui for building them. Easiest way of doing this will be with vertex shaders; you use a small cross-section of the actual track then 'repeat' it across a b-spline.
I mean it can all be done in lua, it would just be a pain to do and there's no real documentation of the new GL4 stuff I'm aware of so you'll have to look at examples or learn from BAR.
Collision detection will also have to be done which should be relatively easy compared to the graphics stuff.
Then you'll need to decide how the train tracks get from point A to point B. You'll need to program in signalling, train scheduling, routes, and a UI for dealing with all these things as well as custom models. What's going to happen when trains collide? When they derail? The built-in physics engine might not be equipped to deal with all this. In fact, with trains most likely having to have unit physics disabled, I doubt the built-in physics engine could be used at all.
This is a lot of effort for a joke mod.