Matt, I'll try and post some suggestions on how you could do the spool up this evening.
Chris
cjbarnes5294 wrote:Matt, I'll try and post some suggestions on how you could do the spool up this evening.
Chris
thisRPM = Call("*:GetControlValue", "RPM", 0);
if lastRPM ~= nil then -- if we stored RPM before
RPMdiff = (thisRPM - lastRPM)/time
if RPMdiff < 0 then
RPMdiff = 0 -- don't accept negative numbers, on RPM decrease just do nothing special
elseif RPMdiff > maxRPMdiff then
RPMdiff = maxRPMdiff -- set some maximum so you are sure about the value range you get
end
volume = RPMdiff * someScalingFactor
end
lastRPM = thisRPM
cjbarnes5294 wrote:I was actually thinking of suggesting more or less what you've done, Andi. I believe there is a control called DeltaRPM but I don't know if it returns what it says on the tin, so I was thinking of working out if the RPM has changed with the script anyway.
However, I'm a bit knackered tonight and just about to turn in, so I'll put up some more details tomorrow, Matt, if that's ok?
Chris
-- the following can be anywhere in the code, outside all functions
-- preferably at the top where it is easily found and modified
red1 = 0.5
green1 = 0.5
blue1 = 0.5
red2 = 0
green2 = 0
blue2 = 1
MaxRpmChangePerSecond = 50 -- copied from engine simulation file
lastRPM = 0 -- hack to simplify the code in Update which is performed often
-- the following isolates the colour mixing in a separate function
function blendExhaust (mix) -- mix = 0 -> only colour 1; mix = 1 -> only colour 2; mix = 0.5 -> half and half
local red = red1 * (mix - 1) + red2 * mix
local green = green1 * (mix - 1) + green2 * mix
local blue = blue1 * (mix - 1) + blue2 * mix
Call ("EmitterName:SetEmitterColour", red, green, blue)
end
-- the following is only a fragment of Update, of course
function Update (time)
thisRPM = Call("*:GetControlValue", "RPM", 0);
RPMdiff = (thisRPM - lastRPM)/ time / MaxRpmChangePerSecond
lastRPM = thisRPM
if RPMdiff < 0 then
RPMdiff = 0 -- don't accept negative numbers, on RPM decrease just do nothing special
elseif RPMdiff > 1 then
RPMdiff = 1 -- set maximum to 1 as this is the maximum input blendExhaust accepts
-- if MaxRpmChangePerSecond is right, this case will not occur, but who knows ...
end
blendExhaust (RPMdiff)
end
AndiS wrote:Glad I left something for you to expand on.
Don't forget that this is all theory, too. Getting it to work can be "fun" still.
But I don't want to take any blame for your exam results, so I will certainly wait patiently, in particular for the coming two weeks that will see me far from RW, so no practical experimenting for me for sure.
Return to Train Simulator Mess Room
Users browsing this forum: No registered users and 2 guests