Page 1 of 1

Looking for some expert advice for exhaust smoke

Unread postPosted: Mon Jan 20, 2020 5:48 am
by railmaster
Hi,
I am fairly new to Train sim and just recently i started modeling and testing out some models of my own( not very good at this point). Can someone please provide me a script to control exhaust smoke. I want my loco to not emit exhaust when it is in idle mode and puff out smoke only when the throttle is increased. I tried to find if anyone had previously posted, but couldn't find any.
Any one please?

Re: Looking for some expert advice for exhaust smoke

Unread postPosted: Mon Jan 20, 2020 11:41 am
by GreatNortherner
Hi,

Have a look at the engine script of the Kuju\RailSimulatorUS F7. It includes load dependent smoke (if I remember correctly) and should be present in uncompiled .lua format.

Cheers
Michael

Re: Looking for some expert advice for exhaust smoke

Unread postPosted: Tue Jan 21, 2020 2:44 am
by railmaster
Thank you for the reply. But there is no RailsimulatorUS folder inside KUJU. All i have is RailsimulatorCore and Shapeviewer !*hp*!

Re: Looking for some expert advice for exhaust smoke

Unread postPosted: Tue Jan 21, 2020 3:42 am
by GreatNortherner
Ah yes, you mentioned that you were new to train sim. The RailSimulatorUS assets originally were the default content of the game in its early years, and are now the content of the US Loco and Assets Pack on Steam -- I didn't consider the chance that you may not actually have that one. It is a requirement for many freeware add-ons and I'd recommend that you pick it up some day -- but wait for a sale and also check before, which older routes it is bundled with. Maybe you can get it with one of them.

Edit: I realize this doesn't help you much in your current situation. But looking at the script, it seems fairly "plug and play" to me, so you should be able to build your engine and then add the script at any point later on.

Cheers
Michael

Re: Looking for some expert advice for exhaust smoke

Unread postPosted: Tue Jan 21, 2020 2:51 pm
by railmaster
*!!thnx!!* I will see if i can get the loco itself on steam.

Re: Looking for some expert advice for exhaust smoke

Unread postPosted: Tue Jan 21, 2020 2:57 pm
by buzz456
Do you have any of the hood units from RSC or DTG? They all basically use the same scripting for the smoke.

Re: Looking for some expert advice for exhaust smoke

Unread postPosted: Tue Jan 21, 2020 4:08 pm
by TheR62Fan
GreatNortherner wrote:It is a requirement for many freeware add-ons and I'd recommend that you pick it up some day -- but wait for a sale and also check before, which older routes it is bundled with. Maybe you can get it with one of them.


Yes, the original RailSimulator Content is one of the most important items you can ever pick up. Highly recommended. I picked up my copy from the original Cajon Pass and Northeast Corridor routes. In fact, the amount of 3rd party content available for these locomotives is just stunning. (I have over 50 different kinds of SD40-2s).

Re: Looking for some expert advice for exhaust smoke

Unread postPosted: Wed Jan 22, 2020 10:12 am
by railmaster
buzz456 wrote:Do you have any of the hood units from RSC or DTG? They all basically use the same scripting for the smoke.

I do have SD40s but the script files are in .out format.

Re: Looking for some expert advice for exhaust smoke

Unread postPosted: Wed Jan 22, 2020 10:36 am
by buzz456
Hood units I was referring to the RSC Empire builder or DTG feather River like f-units or e-units.

Re: Looking for some expert advice for exhaust smoke

Unread postPosted: Wed Jan 22, 2020 10:37 am
by bnsfsubdivision
Code: Select all
--------------------------------------------------------------------------------------
-- Engine Script for SD40-2
--
-- (c) Railsimulator.com 2011
--
-- Provides script for variable exhaust smoke.
--
--------------------------------------------------------------------------------------


-- maximum tractive effort for determining smoke density. Acceleration rate for AI.

MAXTE = 0.5
ACCELRATE = 0.25

gSmokeColourR = 1.0
gSmokeColourG = 1.0
gSmokeColourB = 1.0
gEmitRate = 0.05

-------------------------------------------------------------------------------------

function Initialise ()


-- Get emitter values.

   gSmokeColourR, gSmokeColourG, gSmokeColourB = Call( "Exhaust01:GetEmitterColour" )


-- Stores for checking when values have changed.

   gDriven = 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 )


-- Check for player train.

   if Call( "GetIsPlayer" ) == 1 then

-- Check if player is driving this engine.

      if ( Call( "GetIsEngineWithKey" ) == 1 ) then
         if gDriven == 0 then
            gDriven = 1
            Call( "*:SetControlValue", "Active", 0, 1 )
         end
      else
         if gDriven == 1 then
            gDriven = 0
            Call( "*:SetControlValue", "Active", 0, 0 )
         end
      end

-- Get tractive effort values for this vehicle.
      TractiveEffort = Call ( "GetTractiveEffort" )
      TractiveEffort = math.abs ( TractiveEffort )

   else -- This is an AI train.

-- Tractive effort doesn't work for AI, so use acceleration.

      Accel = Call( "GetAcceleration" )
      Speed = Call( "GetSpeed" )

-- Unfortunately acceleration is signed based on direction loco is facing (sic).
      if Speed < 0 then
         Accel = Accel * -1
      end

      if Accel > ACCELRATE then
         TractiveEffort = MAXTE
      elseif ( math.abs(Speed) > 1 ) and ( Accel > -0.1 ) then
         TractiveEffort = MAXTE/2
      else
         TractiveEffort = MAXTE/11
      end

   end


   if TractiveEffort < MAXTE/10 then
                  
      gSmokeColourR = 0.8
      gSmokeColourG = 0.8
      gSmokeColourB = 0.8
      Call ( "Exhaust:SetEmitterColour", gSmokeColourR, gSmokeColourG, gSmokeColourB )
      Call ( "Exhaust:SetEmitterRate", gEmitRate )

   end
            
   if ( TractiveEffort <= MAXTE/2 ) and ( TractiveEffort >= MAXTE/10 ) then
            
      gSmokeColourR = 0.25
      gSmokeColourG = 0.25
      gSmokeColourB = 0.25
      Call ( "Exhaust:SetEmitterColour", gSmokeColourR, gSmokeColourG, gSmokeColourB )
      Call ( "Exhaust:SetEmitterRate", 0.01 )

   end
      
   if TractiveEffort > MAXTE/2 then
   
      gSmokeColourR = 0.0
      gSmokeColourG = 0.0
      gSmokeColourB = 0.0
      Call ( "Exhaust:SetEmitterColour", gSmokeColourR, gSmokeColourG, gSmokeColourB )
      Call ( "Exhaust:SetEmitterRate", 0.005 )

   end

end


Re: Looking for some expert advice for exhaust smoke

Unread postPosted: Thu Jan 23, 2020 1:39 am
by railmaster
bnsfsubdivision wrote:
Code: Select all
--------------------------------------------------------------------------------------
-- Engine Script for SD40-2
--
-- (c) Railsimulator.com 2011
--
-- Provides script for variable exhaust smoke.
--
--------------------------------------------------------------------------------------


-- maximum tractive effort for determining smoke density. Acceleration rate for AI.

MAXTE = 0.5
ACCELRATE = 0.25

gSmokeColourR = 1.0
gSmokeColourG = 1.0
gSmokeColourB = 1.0
gEmitRate = 0.05

-------------------------------------------------------------------------------------

function Initialise ()


-- Get emitter values.

   gSmokeColourR, gSmokeColourG, gSmokeColourB = Call( "Exhaust01:GetEmitterColour" )


-- Stores for checking when values have changed.

   gDriven = 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 )


-- Check for player train.

   if Call( "GetIsPlayer" ) == 1 then

-- Check if player is driving this engine.

      if ( Call( "GetIsEngineWithKey" ) == 1 ) then
         if gDriven == 0 then
            gDriven = 1
            Call( "*:SetControlValue", "Active", 0, 1 )
         end
      else
         if gDriven == 1 then
            gDriven = 0
            Call( "*:SetControlValue", "Active", 0, 0 )
         end
      end

-- Get tractive effort values for this vehicle.
      TractiveEffort = Call ( "GetTractiveEffort" )
      TractiveEffort = math.abs ( TractiveEffort )

   else -- This is an AI train.

-- Tractive effort doesn't work for AI, so use acceleration.

      Accel = Call( "GetAcceleration" )
      Speed = Call( "GetSpeed" )

-- Unfortunately acceleration is signed based on direction loco is facing (sic).
      if Speed < 0 then
         Accel = Accel * -1
      end

      if Accel > ACCELRATE then
         TractiveEffort = MAXTE
      elseif ( math.abs(Speed) > 1 ) and ( Accel > -0.1 ) then
         TractiveEffort = MAXTE/2
      else
         TractiveEffort = MAXTE/11
      end

   end


   if TractiveEffort < MAXTE/10 then
                  
      gSmokeColourR = 0.8
      gSmokeColourG = 0.8
      gSmokeColourB = 0.8
      Call ( "Exhaust:SetEmitterColour", gSmokeColourR, gSmokeColourG, gSmokeColourB )
      Call ( "Exhaust:SetEmitterRate", gEmitRate )

   end
            
   if ( TractiveEffort <= MAXTE/2 ) and ( TractiveEffort >= MAXTE/10 ) then
            
      gSmokeColourR = 0.25
      gSmokeColourG = 0.25
      gSmokeColourB = 0.25
      Call ( "Exhaust:SetEmitterColour", gSmokeColourR, gSmokeColourG, gSmokeColourB )
      Call ( "Exhaust:SetEmitterRate", 0.01 )

   end
      
   if TractiveEffort > MAXTE/2 then
   
      gSmokeColourR = 0.0
      gSmokeColourG = 0.0
      gSmokeColourB = 0.0
      Call ( "Exhaust:SetEmitterColour", gSmokeColourR, gSmokeColourG, gSmokeColourB )
      Call ( "Exhaust:SetEmitterRate", 0.005 )

   end

end


*!!thnx!!*