I will be cool if you make a signal for tracks what make a Honk when a train arive it ...
Before crosses with "humans" it you will hear that something is coming.
That will be cool and safety!
Add a green wire to a rail signal next to a train stop or crossing, then a speaker to the signal with the red or yellow signal. I like the triangle sound effect, from the drumkit.
How about on_player_changed_position -> find rail -> get_rail_segment_entity() -> read signal?
If the signal isn't green the rail isn't safe. You could honk at the player then, or try to find the train in the segment.