Not sure how many folks have been following this thread on another board, but for those who have not I figured I'd post my findings here
The first thing I recommend is getting Pike's tutorial on how to update your freight car fleet using InfoRapid Search & Replace. The tutorial can be found on his website, [url][http://www.pikesproducts.com/14201.html/url] item #8. The hard part is manually updating your locomotive fleet. You can either use RW_Tools to edit the engines bin files, or after linking your bin files to serz.exe, use a text editor to edit the xml files. For a text editor I prefer the ConText editor. Now onto the upgrade :)
The first thing you'll have to add to then engines bin file is the active paragraph:
- Code: Select all
<cControlContainerBlueprint-cControlValue d:id="90078136">
<ControlName d:type="cDeltaString">Active</ControlName>
<DefaultValue d:type="sFloat32" d:alt_encoding="0000000000000000" d:precision="string">0.0000</DefaultValue>
<MinimumValue d:type="sFloat32" d:alt_encoding="0000000000000000" d:precision="string">0.0000</MinimumValue>
<MaximumValue d:type="sFloat32" d:alt_encoding="000000000000F03F" d:precision="string">1.0000</MaximumValue>
<BriefDescription d:type="cDeltaString"></BriefDescription>
<DetailedDescription d:type="cDeltaString"></DetailedDescription>
<ApplyToConsist d:type="cDeltaString">eTrue</ApplyToConsist>
<InterfaceElements/>
</cControlContainerBlueprint-cControlValue>
This paragraph is inserted just above the RPM paragraph and just below the opening paragraph statement <ControlValues>
Next search for the Regulator paragraph, you need to update the line ApplyToConsist, it's currently set to eFalse, change it to read eTrue Then save the file.
Next you'll need to add a engine script to each locomotives Engine folder.
- Code: Select all
--------------------------------------------------------------------------------------
-- Engine Script for controlling additional engines
-- RailWorks 2: Train Simulator
--------------------------------------------------------------------------------------
IDLERPM = 1000
FULLRPM = 1500
RPM_ID = 1709
RPMD_ID = 1710
function Initialise ()
gPrevRPM = 0
gPrevRPMDelta = 0
Call( "BeginUpdate" )
end
function OnControlValueChange ( name, index, value )
if Call( "*:ControlExists", name, index ) then
Call( "*:SetControlValue", name, index, value );
end
end
function Update ( time )
-- Get rpm values for this vehicle.
rpm = Call( "*:GetControlValue", "RPM", 0 )
rpm_change = Call( "*:GetControlValue", "RPMDelta", 0 )
if ( Call( "*:GetControlValue", "RPM", 0 ) < 200 ) then
Call( "Exhaust:SetEmitterActive", 0 )
else
Call( "Exhaust:SetEmitterActive", 1 )
end
-- If this is a player train and this vehicle is the driven one, then send
-- RPM values in both directions along train. Note the Driven control is set
-- by the simulation script, which only runs on the vehicle the player is driving.
-- Only send messages if values have changed.
if ( Call( "GetIsPlayer" ) == 1 ) then
if ( Call( "*:GetControlValue", "Active", 0 ) == 1 ) then
if ( rpm ~= gPrevRPM ) then
Call( "SendConsistMessage", RPM_ID, rpm, 1 )
Call( "SendConsistMessage", RPM_ID, rpm, 0 )
end
if ( rpm_change ~= gPrevRPMDelta ) then
Call( "SendConsistMessage", RPMD_ID, rpm_change, 1 )
Call( "SendConsistMessage", RPMD_ID, rpm_change, 0 )
end
end
gPrevRPM = rpm
gPrevRPMDelta = rpm_change
end
end
-- Core sim function executed if a consist message is received.
function OnConsistMessage ( msg, argument, direction )
-- If this is not the driven vehicle then update the controls for RPM values with the supplied data.
if ( Call( "*:GetControlValue", "Active", 0 ) == 0 ) then
if ( msg == RPM_ID ) then
Call( "*:SetControlValue", "RPM", 0, argument )
elseif ( msg == RPMD_ID ) then
Call( "*:SetControlValue", "RPMDelta", 0, argument )
end
-- Pass message along in same direction.
Call( "SendConsistMessage", msg, argument, direction )
end
end
The above script will work for just about all locomotive with just a couple of simple changes. First change, open your engines bin file and search for
ScriptComponent
To find the name of the script the engine will use, in this case I'm using the Black ES44AC as an example engine, so the line I'm looking for reads:
- Code: Select all
<Name d:type="cDeltaString">Kuju\RailSimulatorUS\RailVehicles\Diesel\ES44AC\Black\Engine\ES44ACEngineScript</Name>
The name of the script is: ES44ACEngineScript, so your script file needs to be named ES44ACEngineScript.lua
Now scroll up about 40 lines and you should see a line that contains the word Exhaust. Again using the Black ES44AC as an example the line reads:
- Code: Select all
<ChildName d:type="cDeltaString">Exhaust</ChildName>
Make a note of the exact word or words used between the greater than and less than symbols, they could be Diesel_Exhaust, Engine_Exhaust and so forth. Now that you know the name of the exhaust, open the engine script file and search for the text:
SetEmitterActive
In this case I'm again using the Black ES44ACEngineScript.lua as an example:
- Code: Select all
Call( "Exhaust:SetEmitterActive"
Notice the word before the colon, if your engines exhaust statement read Engine_Exhaust, then you'd need to change the above statement to
- Code: Select all
Call( "Engine_Exhaust:SetEmitterActive"
Now save the file. The last thing you'll need to do is add a script file to any locomotive that has a Simulation folder. This script file is placed in the Simulation folder.
- Code: Select all
--------------------------------------------------------------------------------------
-- Simulation Script for controlling audio in additional engines
-- RailWorks 2: Train Simulator
--------------------------------------------------------------------------------------
-- Update
function Update (inteval)
-- If simulation is running this must be player vehicle, so set Active control to indicate this.
Call( "*:SetControlValue", "Active", 0, 1 )
end
This file should have the same file name as the bin file in the simulation folder, except the file extension should be lua.
That's it and if all went well, all of your engines in a consists should now produce sound and the exhausts on all engines should emit smoke :) Also if you followed Pike's tutorial to update your freight car fleet, you helper engines and DPU engines should throttle up and emit exhaust as well ;) Lastly I'd like to thank TomKat, Krellnut, MontanaRails and Otto for all of their help on this project, thanks guys
Enjoy,
Rich S.

and Thank you for automating this process through RW_Tools. 
