Can you change the direction of a func_train using a button? I see in the example maps you can change the speed, but I can't seem to figure out how to reverse the train or have it choose the alt forward path.
You can change the direction of a func_train via a trigger but, its not a simple task to setup. Ideally it should of been something easy to implement, but alas it did not turn out that way. So, lets start with the new func_train test map ...
Before I get into the nuts and bolts I recommend that func_train entities in AD are lit in separate spaces of the map, so that they have more uniform / consisent lighting. Underneath the main area of the test map are three separate boxes (covered in skip texture) that the func_train entities spawn into and once the map is loaded, they are moved into position (above) ready for use.
The problems of going backwards ...
Func_train entities can start with a REVERSE direction spawnflag, but this is only set once when the map starts and cannot be toggled directly. Another way to switch func_train direction is to use the REVERSE spawnflag on the path_corner entities, but this creates a bounce effect where the train will go back and forth instead of just going forward OR backward. The best solution is to modify the path_corner entities to switch between the two "forward" routes. Unfortunately using the proper backward route does not work correctly because it creates a bouncing loop between two path_corner entities instead. I know this is misleading, but its something that was overlooked at the time.
The test map has 3 func_train setups, with the back two (next to the exit teleporter) showing the REVERSE spawnflag options on func_train and path_corner entities and how they are not suitable as a switchable trigger event. These are included in the test map to show how the reverse spawnflag feature works but, they are not relevant for the requested setup.
The correct solution is the first one (directly infront of the player) with a func_train waiting to start with a floor button. Once the train has started moving the right hand wall shoot button is available to toggle the direction of the train, either forward or backward around the small loop.
There are a lot of tricky things going on with this setup, so lets start with what is required first ...
* All the path_corner entities have to use the EXACT spawnflag option, otherwise route switching will not work correctly.
* Every path_corner entity has to be updated via a trigger_relay to switch its route state (forward=1, forward alt=2).
* The path_corner entities need to be all setup to use "target2" keys. This is the fake "backward" route.
The shootable wall button will fire a trigger_relay located in the middle of the train loop area. This relay has the TOGGLE spawnflag enabled and a target/target2 setup defined. This relay will cycle between the target/target2 keys everytime its fired by the func_button. This is the toggle logic (its optional, but it shows the switching of the train direction perfectly)
The middle trigger_relay then fires a further set of trigger_relay entities (this is the core logic and what does the switching) around it that change the exact route direction of the path_corner entities. (if developer 1 is enabled, this switch event is mirrored to the console for debug reasons) This is how to make the train switch between route 1 (forward) and route 2 (forward alt) or vice versa. Every path_corner entity in the chain will need an extra trigger_relay entity to switch between the routes. In the test map you can see the two extra trigger_relay entities above every path_corner entity. (This is for visual reasons, so its easier to know how entities are connected)
Hope that helps, if
@madscientist got any more questions, ask away.