Is it possible to disable some functions of a train?

General discussion about Train Simulator, your thoughts, questions, news and views!

Moderator: Moderators

Locked
clkgtr
Getting the hang of things now
Posts: 48
Joined: Sun Jul 15, 2012 3:00 am

Is it possible to disable some functions of a train?

Post by clkgtr »

Hello,
I am working on a scripted scenario of my route, I just think if there is a way to disable some functions of a train or not. For example ,a train has a cruise control ,but in a special scenario ,I just want to cruise control unable to use.
I only found in scritped scenario ,it can lock all the controls but what about only a part of them ?
Any tips ,thanks.
User avatar
Irishrailguy
Very Active Forum Member
Posts: 1338
Joined: Sun Mar 21, 2010 8:58 pm
Location: Dublin, Ireland

Re: Is it possible to disable some functions of a train?

Post by Irishrailguy »

For an individual control, you could try to do it via scripting, although I'm not sure if it's possible through a scenario script as I don't work with scenarios myself. Try putting something like this into an update(interval) function for the player consist:

Code: Select all

function Update (interval)

       if (Call("*:GetControlValue", "SpeedSet", 0) == 1) --The user has turned on the cruise control
             
              Call("SetControlValue", "SpeedSet", 0, 1) --Reset the cruise control

       end
end
Do remember that this is just pseudo-code. I don't have the RSC 377 at hand at the moment, so I don't know the names of the control values used to control the cruise control or whether anything above actually works. But you'll need to find out how the particular unit you're working with operates so you can find out which control needs to be set to a constant so it doesn't interfere with the user.

Kev
User avatar
ChrisBarnes
Very Active Forum Member
Posts: 1494
Joined: Sat Jul 25, 2009 3:45 pm
Location: North Yorkshire

Re: Is it possible to disable some functions of a train?

Post by ChrisBarnes »

If the cruise control is a control that a player can turn on and off at a button press or lever switch, and you simply want to prevent a player from using it, then this might work:

Code: Select all

SysCall ( "PlayerEngine:SetControlValue", "ControlName", 0, 0); --ensure control is turned off or whatever
SysCall ( "PlayerEngine:LockControl", "ControlName", 0, 1); --lock it 
Since I've never written a scenario script, I'm not sure how you could implement it although I suppose you could have something like:

Code: Select all

function OnEvent ( event )
	if (event == "Start") then
		SysCall ( "PlayerEngine:SetControlValue", "ControlName", 0, 0); --ensure control is turned off or whatever
                SysCall ( "PlayerEngine:LockControl", "ControlName", 0, 1); --lock it 
		return TRUE;
	elseif (event == "Finish") then
                --do whatever you want
	end
	
	return FALSE;
end
Chris
Just Trains BR 4, 5, 6, 7 and LNER K4 & V2 script and simulation author
clkgtr
Getting the hang of things now
Posts: 48
Joined: Sun Jul 15, 2012 3:00 am

Re: Is it possible to disable some functions of a train?

Post by clkgtr »

Hello
Thanks very much, you helped me a lot.I will try it later in game.
Liu
Locked

Return to “[TS] General Discussion”