New Driver Command: Play Horn up to 10 times

ffccnn

Member
I got sick of inserting Hornz, Hornz, Hornz, ... in a train schedule.
I create a driver command to play the horn 1, 2, up to 10 times.
The config file has these entries:

Code:
  play_0_label                          "Play once"
  play_1_label                          "Play twice"
  play_2_label                          "Play 3 times"
  play_3_label                          "Play 4 times"
  play_4_label                          "Play 5 times"
  play_5_label                          "Play 6 times"
  play_6_label                          "Play 7 times"
  play_7_label                          "Play 8 times"
  play_8_label                          "Play 9 times"
  play_9_label                          "Play 10 times"
  play_0_val                            "1"
  play_1_val                            "2"
  play_2_val                            "3"
  play_3_val                            "4"
  play_4_val                            "5"
  play_5_val                            "6"
  play_6_val                            "7"
  play_7_val                            "8"
  play_8_val                            "9"
  play_9_val                            "10"
  delay_millisecs                       "200"

The delay is used between each play to put the running thread to sleep while the sound comes out.
The 'play_x_val' tag's values are the number of times that the horn is blasted.

You would tune up the delay in millisecs to get a better sequence if it is needed. The values of the tags can be changed but not the names of the tags or you would screw up the script.

Here is a demo: http://youtu.be/JZjxxb-BkBw

If anyone is interested I will upload it.

cheers,

José
 
I'm interested, I've played with the regular command as well as the trackmark gadget, which also needs a tedious number festooning the track to make a single long blast. Can you do something similar for bells, EG bell on for X number of seconds/minutes/rings/whatever then off with a single command? The way it is now for an approach to a station requires something like drive via trackmark 05, bellz (on), hornz hornz hornz hornz wait 5 seconds hornz hornz hornz hornz drive to station bellz (off) load passengers for X seconds bellz (on) hornz hornz hornz hornz wait 5 seconds hornz hornz hornz hornz drive via trackmark 06 bellz (off) drive to / via next trackmark. Whew. All that to make one stop, repeat for all stops, change format for through freights to blow twice and ring the bell passing the station then shut it off.
 
....Can you do something similar for bells, EG bell on for X number of seconds/minutes/rings/whatever then off with a single command? ....

Hi Sniper,
Let's see if I understood it. Do you want the train to play the bell for some time while still moving to a station? or do you wish just play the bell for some time?

The former can't be a driver command, I am thinking of an action spawned by a trigger. The latter would be similar to the new command I am posting about in this thread.

Please clarify

cheers,

José
 
HI Jose I agree with you that the inserting Hornz in a train schedule repeatedly is frustrating and not very Prototypical.

It is nice to see something being done to address this issue.

To Be able to select the length at which the horn is sounded may help to bring us closer to recreating Whistle signals that could be used by AI trains

in yards, crossings approaching stations etc.

I find it easy to do when driving a train in cab mode, but when you encounter or are near AI trains who do there one short Hornz sound the realism is a bit diminished.

For those of you not familiar with Whistle signals have a look here.

http://en.wikipedia.org/wiki/Train_whistle

http://trn.trains.com/Railroad%20Reference/ABCs%20of%20Railroading/2006/05/Whistle%20signals.aspx

Thank you Jose I look forward to trying your new command and watching further developments.

Cheers Jimbo.
 
thanks metrocentral for those links, very informative. Once I upload the new command, let's see if we can create one of those sequences described in your links.
For example, - - 0 - Approaching public grade crossing,
could be created in the schedule library with this sequence:
HornzExtended(6)
HornzExtended(6)
HornzExtended(1)
HornzExtended(6)

where HornzExtended is the name of my new command.

cheers

José
 
"Do you want the train to play the bell for some time while still moving to a station? or do you wish just play the bell for some time?"

Same thing AFAIK, the standard bellz command toggles it on and off, if the train is rolling it keeps rolling. What I'm thinking is eliminate extra trackmarks by having a single command turn it on, then shut it off after X number of rings, seconds, minutes, or meters of travel, whatever works.
 
This is a great idea and it beats trying to setup an HTML-driven script file which was awful.

I still see needing a trigger or track mark to trigger the horn and bell though because we want the drivers to blow and ring for crossings, and ring for stations. The problem I found with triggered actions like this seems to be that they only work once for some reason then they quit working for that track mark. I could never get the horn one I had to play more than once and only for one train. The other problem with this has to do with running on single track. The train will blow/ring for one track mark, cross over the crossing and start blowing again for the track mark that was to be used for the other direction.

John
 
Chistmas is my favorite time of the year! yeah, I am taking some time off finally and so I play Trainz late at night, several cups of coffee, classical music, what else can I ask for?

Well, the command has been uploaded:

HornzExtended.cdp
Date Received: 20th Dec 2012, 16:18:42 (AEST)
Upload Mode: Preview Area
Waiting to be Processed.

It seems that it would take up to 5 days to be processed. If you want to try it before I could email it to you, just drop a message.
 
I got the news it is now available. Let's see how it plays. I am sure it will need some tune up but I think it is a good start, better than nothing.

Your uploaded content listed below has been approved and will be available for download within 24 hours.

HornzExtended <KUID:478639:100034>
TrainProductInfo <KUID2:478639:1058:2>
 
HI Jose I have been experimenting with your new Hornz command and I like it.

It's bringing us closer to replicating whistle signals.

I set up a session using Your new Hornz Extended Command and the Original Wait For Command.

The only problem I now see has to do with Wait For Command, and the amount of seconds

between the horn sounding.

The minimum 5 Seconds currently available is just a bit to long.

What we need is one that lets us select between increments of say 1-10 seconds etc.

So when setting up a session for the Ai Locomotive, an example might be Horn - Wait For 3 Seconds - Horn - Wait For 2 Seconds- Horn etc.

If we had a new Wait For Command that gave greater flexibility for seconds or even minutes, then we could have better control

over the horn.

Cheers

Jimbo.
 
Hi Jimbo,
I doubt we can get such a fine control up to the second, normally the system works by posting messages and they are not guaranteed to be delivered with such a precision.
Try changing these two settings in the config.txt file to see if you can get a better tune up:

delay_millisecs "200"
delay_sequence "500"

delay_millisecs is the time the system sleeps between each repetition of the horn, so if you selected to play it 5 times, HornEx(5), the program goes like horn-sleep-horn-sleep-horn-sleep-horn-sleep-horn----- and then it sleeps the delay_sequence.

Now if you setup a schedule with three HornExtendeds like HornEx(5)-HornEx(5)-HornEx(5) the delay_sequence put the system to sleep that amount of millisecs between each HornEx(5).

I tried many different ways to play the horn and the best I got is shown here:

Code:
   while(playCounter > 0)
   {
    //Router.PostMessage(driver.GetId(), train.GetId(), "loco", "horn", 0.0);
    train.SoundHorn();
    //World.Play2DSound(hornsoundAsset, "horn_start.wav"); // "horn_loop.wav");
    playCounter = playCounter - 1;
    if(playCounter > 0)
    {
     train.Sleep(playDelay);
    }
   }
   if(delaySequence > 0.0f)
   {
    train.Sleep(delaySequence);
   }

Anyways, I am not an expert aboout playing sounds, all I know is how to turn on/off my stereo system :)

cheers,

José
 
Last edited:
What we need is one that lets us select between increments of say 1-10 seconds etc.

Jimbo,
I'll try that later, right now I am doing a complete Blender course so I will be able to do my own models and not depend on someone else to let me use their stuff.

José
 
Hi José, Not to be bumpping your post but i seen you updated your train Product info,command what did you change? I didn't see anything new.
I would like to have seen a # of cars.
 
Hi José, Not to be bumpping your post but i seen you updated your train Product info,command what did you change? I didn't see anything new.
I would like to have seen a # of cars.

Hi Danny5,

I like your idea to show the number of cars in the consist, I'll do that, thanks for the tip.
The updated version was for a bug in the code, IIRC it was a null pointer exception.
I'll let you know when a new version is loaded.

Merry Christmas


--José
 
Hello sir Please Help me

I have 50 KM long track. Road Crossing is 1 KM away from Station. It takes 1 minute to reach there. I want Horn will continuesly to play for 1minute. I there any way
 
José, I just downloaded your horn and bell trigger. They work great for setting off the horn and bell as the train enters a station. I was going to use them on the UMR multiplayer session but I have one problem. They are not directional. A lot of the stations on this route have trains entering from both directions. If I place the triggers at both ends the horn and bell are set off as the train leaves the station also. Anyway to make these triggers directional? Carl
 
Does this command (or another one) trigger the long-long-short-long for a grade crossing when the locomotive has a horn that is just and on/off type? By that I mean that it is the kind that goes on with the H key, and off when you release the H key, and it is NOT the kind that if you tap the H key, you get a full long-long-short-long no matter what.
 
I am also seeking a directional trigger for HORNZ.

Is it possible to make it in synch with ATLS. I mean there are two triggers, one for setting on the horn and other one to turn the horn OFF.
S IT POIBLE
 
José, I just downloaded your horn and bell trigger. They work great for setting off the horn and bell as the train enters a station. I was going to use them on the UMR multiplayer session but I have one problem. They are not directional. A lot of the stations on this route have trains entering from both directions. If I place the triggers at both ends the horn and bell are set off as the train leaves the station also. Anyway to make these triggers directional? Carl

Hi Lewiscc65,
Good idea to make both triggers directional, I think as an option in the configuration screen. Since my vacation time is coming to an end, I wll back in the office by Jan 2 :( I will try to figure out how to make them directional this last weekend before going to the "grinding machine" again.

Happy new year.

--José
 
Back
Top