Kali wrote:I have a cacheing control read/write library that's possibly bundled in with the autonumber stuff I posted already that's inherently RD safe ( by virtue of only ever setting *any* control if the value's changed ) that I don't mind anyone using. I suspect my local copy is a bit newer, mind.
where is it?
Machinist wrote:You missed many many things....![]()
RailDriver problems with some new assets
viewtopic.php?f=29&t=3172
Kali wrote:I knocked up a stand-alone version, it's attached. It's prototype code ( I'm doing a whole new set of libraries ) but it should be perfectly functional - let me know if it's not ( and note all I've done with this version is run luac -p over it ).
To use: add
require("/path/to/library/ControlCacheSA.lua")
to the script & start using the functions. Note that I think lua paths use unix-type "/".
require("Assets/K-rail/Scripts/Generic/ControlCacheSA.lua")
--------------------------------------------------------------------------------------
-- Engine Script for AEM7 electric locomotive
-- RailWorks 2: Train Simulator
--------------------------------------------------------------------------------------
--
-- Updates controls, reads messages from signals and set engine controls for
-- cab signalling. Controls flashing of appropriate aspects.
--
--------------------------------------------------------------------------------------
-- Boolean.
TRUE = 1
FALSE = 0
ON = 1
OFF = 0
-- For light flash rate.
LIGHT_FLASH_ON_SECS = 0.5
-- Cab signal states.
NONE = 0
CLR = 1
CABSPD8 = 2
CABSPD6 = 3
APPLIM = 4
APPMED = 5
APP = 6
RESTRICT = 7
IGNORE = 8
function Initialise ()
-- Initial cab signal states.
gCabSignal = NONE
gTrackSpeed = DASH
-- State of flashing for appropriate cab signal aspects.
gTimeSinceLastFlash = 0
gLightFlashOn = FALSE
end
function OnControlValueChange ( name, index, value )
if Call( "*:ControlExists", name, index ) then
Call( "*:SetControlValue", name, index, value );
end
end
function OnCustomSignalMessage ( Parameter )
if ( Call( "GetIsPlayer" ) == TRUE ) then
newsig = string.sub ( Parameter, 4, 4 )
if (newsig+0) ~= IGNORE then
gCabSignal = newsig
end
gTrackSpeed = string.sub ( Parameter, 8 )
Print( (" consist signal: " .. gCabSignal ) )
Print( (" consist speed: " .. gTrackSpeed) )
currentSig = Call( "*:GetControlValue", "CabSignal", 0 )
currentTrk = Call( "*:GetControlValue", "TrackSpeed", 0 )
-- Add zeros to comparisons to ensure the strings are converted to type number.
if (( currentSig + 0 ) ~= ( gCabSignal + 0 )) and ((newsig+0) ~= IGNORE ) then
Call( "*:SetControlValue", "CabSignal", 0, gCabSignal )
Call( "*:SetControlValue", "AlertLight", 0, TRUE )
Call( "*:SetControlValue", "AWSWarnCount", 0, TRUE )
end
if ( (gCabSignal+0) == APPLIM ) then
Call( "*:SetControlValue", "CabSignal1", 0, OFF )
Call( "BeginUpdate" )
elseif ( (gCabSignal+0) == CABSPD8 ) or ( (gCabSignal+0) == CABSPD6 ) then
Call( "*:SetControlValue", "CabSignal2", 0, OFF )
Call( "BeginUpdate" )
elseif (gCabSignal+0) == APPMED then
Call( "*:SetControlValue", "CabSignal2", 0, ON )
Call( "*:SetControlValue", "CabSignal1", 0, OFF )
elseif (gCabSignal+0) == CLR then
Call( "*:SetControlValue", "CabSignal1", 0, ON )
Call( "*:SetControlValue", "CabSignal2", 0, OFF )
elseif (newsig+0) ~= IGNORE then
Call( "*:SetControlValue", "CabSignal1", 0, OFF )
Call( "*:SetControlValue", "CabSignal2", 0, OFF )
end
if ( currentTrk + 0 ) ~= ( gTrackSpeed + 0 ) then
Call( "*:SetControlValue", "TrackSpeed", 0, (gTrackSpeed + 0) )
Call( "*:SetControlValue", "AlertLight", 0, TRUE )
Call( "*:SetControlValue", "AWSWarnCount", 0, TRUE )
end
end
end
function Update ( time )
gTimeSinceLastFlash = gTimeSinceLastFlash + time
if gTimeSinceLastFlash > LIGHT_FLASH_ON_SECS then
gTimeSinceLastFlash = 0
if gLightFlashOn == FALSE then
gLightFlashOn = TRUE
if ((gCabSignal+0) == CABSPD8) or ((gCabSignal+0) == CABSPD6) then
Call( "*:SetControlValue", "CabSignal1", 0, ON )
elseif ((gCabSignal+0) == APPLIM) then
Call( "*:SetControlValue", "CabSignal2", 0, ON )
end
else
gLightFlashOn = FALSE
if ((gCabSignal+0) == CABSPD8) or ((gCabSignal+0) == CABSPD6) then
Call( "*:SetControlValue", "CabSignal1", 0, OFF )
elseif ((gCabSignal+0) == APPLIM) then
Call( "*:SetControlValue", "CabSignal2", 0, OFF )
end
end
end
if ((gCabSignal+0) ~= CABSPD6) and
((gCabSignal+0) ~= CABSPD8) and
((gCabSignal+0) ~= APPLIM) then
gLightFlashOn = FALSE
gTimeSinceLastFlash = 0
Call ("EndUpdate")
end
end
b737lvr wrote:I think its safe to say RD isn't very user friendly.
hminky wrote:Raildriver isn't the problem. They have been sold since 2002. Producing equipment that doesn't work with the "Defacto" controller is on the game developer. Sorta like an Xbox game not working with an Xbox controller.
Harold
I couldn't say it better... in fact RSC invented that weird (to say the least) F4 virtual console to be played with mouse (absurde!), and seems to not be worried enough with users that need a more immersive experience. I've been following P.I. Engineering try to get from RSC the new codes (mostly TS2012 new engines) to fix the problems but RSC doesn't help.Machinist wrote:I couldn't say it better... in fact RSC invented that weird (to say the least) F4 virtual console to be played with mouse (absurde!), and seems to not be worried enough with users that need a more immersive experience. I've been following P.I. Engineering try to get from RSC the new codes (mostly TS2012 new engines) to fix the problems but RSC doesn't help.
hminky wrote:Raildriver hasn't supported steam locomotives in Trainz since TS2009 because of a change in coding and the Raildriver people haven't fixed that problem probably because Raildriver and steam use in Trainz is really low. Since there are fewer people using Railworks so I don't expect them to fix the problems since RSC is the problem.
I run mostly OpenRails lately, MSTS is ugly but definitely more immersive.
Harold
Users browsing this forum: No registered users and 12 guests