Page 1 of 1

Limits of shunt signals

PostPosted: Tue May 02, 2017 7:24 pm
by brysonman46
I am using Mark Brinton's SR LoS boards, which are track linked. Is there any way in which I can penalise a player who makes a shunt movement beyond a board?

Nick

Re: Limits of shunt signals

PostPosted: Wed May 03, 2017 9:21 am
by AndiS
You can always send anyone a SPAD message when you see fit. Whether that ends the game for the player depends on the game settings.

If you give me the exact asset name, I can tell you whether that happens anyway or what to do to make it happen.

The hook attached here is that everyone gets the message. There is no way for the game to know whether it is a shunting movement or a running movement, unless you go for all new scripts with movement predictors that are placed by the scenario author to make this distinction.

Re: Limits of shunt signals

PostPosted: Wed May 03, 2017 2:11 pm
by brysonman46
This is in a scenario that is ONLY shunting, within the confines of a yard. Hence, going outside the yard boundaries should constitute a fail. However, there will be other scenarios in which a loco will pick up consists from within the yard, and take them beyond the LoS boards. Hence, I do not wish a feature that is general (ie built into the route). The file can be found at
Assets\MBrinton\RailNetwork\signals\signal_shunting\Sig LOS.bin
I assume that a lua script should do the trick?

Re: Limits of shunt signals

PostPosted: Wed May 03, 2017 8:57 pm
by AndiS
Mark used quite complex stuff from his library. I guess the following would do:
Code: Select all
function Initialise ()
   Call( "Set2DMapSignalState", BLOCKED )
end

-- Send SPAD message to anyone passing any link (i.e., the only link) in forward direction
function OnConsistPass ( prevFrontDist, prevBackDist, frontDist, backDist, linkIndex )
   if (prevFrontDist > 0 and frontDist <= 0) then
      Call( "SendConsistMessage", SPAD_MESSAGE, "" )
   end
end

-- Update is never called but better have it defined.
function Update (time)
end

-- Relay any message - more important than one thinks
function OnSignalMessage( message, parameter, direction, linkIndex )
   if parameter ~= "DoNotForward" and message ~= RESET_SIGNAL_STATE then
      Call( "SendSignalMessage", message, parameter, -direction, 1, linkIndex )
   end
end


Just stick it a new .lua file and change the script entry in a copy of his Sig LoS.xml.

Re: Limits of shunt signals

PostPosted: Thu May 04, 2017 7:18 am
by brysonman46
Thanks Andi. Not sure how to implement this fix. Are you suggesting that I clone the LoS signal, and amend the blueprint of the clone? Then create a lua script for the scenario? I was hoping that I could just create a lua script similar to the ones that detect one's speed, and if it exceeds the speed limit then acts accordingly (eg first time warning, second time ends game).

Re: Limits of shunt signals

PostPosted: Thu May 04, 2017 11:09 am
by AndiS
You need to clone the original signal anyway, or else every LoS signal on your disk changes to the new behaviour. And if you distribute the route, either no one sees the new behaviour, or you distribute your signal modification with the route and everyone has that then on all their routes.

So, yes, make a copy of Sig LOS.xml, change the name in all the languages and the link to the script. The script is a new file containing the code above.

Now if you dream about a remote sensing TPWS OSS build into a LoS, you need quite a different OnConsistPass function. It could look like this:

Code: Select all
function OnConsistPass ( prevFrontDist, prevBackDist, frontDist, backDist, linkIndex )
   -- Send SPAD message to anyone passing any link (i.e., the only link) in forward direction
   if (prevFrontDist > 0 and frontDist <= 0) then
      Call( "SendConsistMessage", SPAD_MESSAGE, "" )
   end
   -- Send overspeed message to anyone approaching this signal within 100 m at more than 15 mph
   if (prevFrontDist > frontDist and frontDist < 100) then
      local consistSpeed = Call("GetConsistSpeed") / 1609 * 3600
     if consistSpeed > 15 then
        Call("SendConsistMessage", TPWS_MESSAGE, "overspeed")
     end
   end
end

Of course, the 100 m and the 15 mph are just my guess. Anything you do will be fine for you if it is what you want.
And no, I did not test that. I just lifted the lines from a few places.

Re: Limits of shunt signals

PostPosted: Thu May 04, 2017 12:29 pm
by brysonman46
I think that I will, for the moment, put this on the back burner. It is just for 1 scenario at one yard. I am using a Marshall command, and there are 2 or 3 ways to complete it. Only one keeps the player within the LoS limits. I will leave it to the player's conscience as to whether they do or not. I need to learn a bit more about the programming and scripting needed - I am a relative caveman having been brought up on Pascal, Fortran, Cobol, Forth, Basic, and Assembly languages (and some HTML).
Many thanks for your efforts.