Bits and pieces about signals and AI

A collection of tutorials, guides and FAQ's.
Forum rules
Please only create new topics if you are posting a new guide, tutorial or FAQ.

Feel free to post in any existing topic asking questions, seeking clarification etc.

Re: Bits and pieces about signals and AI

Postby malkymackay » Wed Apr 16, 2014 5:40 pm

I can report that I have just successfully tested this & witnessed permissive working with 2 units at Kings Cross. :D
User avatar
malkymackay
Full Time Fireman
 
Posts: 87
Images: 58
Joined: Thu Apr 10, 2014 9:19 am
Location: Kilsyth, Scotland
Has thanked: 36 times
Been thanked: 127 times

Re: Bits and pieces about signals and AI

Postby AndiS » Tue Dec 30, 2014 9:38 am

Simulating TAB pressing for all trains (including AI)

The following was tested with JT signals by Rob (Widewanderer) with success. It sends a message indicating that TAB was pressed and the game agreed the signal ahead. This is supposed to cause some call-on aspect to show there, fully depending on the implementation of that other signal.

Code: Select all
--------------------------------------------------------------------------------------
-- Do nothing but sending message REQUEST_TO_PASS_DANGER to the signal ahead
-- under the condition that that signal is closed.
-- AndiS, 30 Dec 2014
-- Place this in approach to a signal with a some call-on indication showing when you press TAB
-- Warning: Of course, this depends on the code of the main signal.
-- All it does is simulating the TAB press.
--------------------------------------------------------------------------------------

function Initialise ()
end

function Update(time)
end

function OnConsistPass ( prevFrontDist, prevBackDist, frontDist, backDist, linkIndex )
   if frontDist <= 0 and prevFrontDist > 0 then   -- front passed link 0 proper
      if 2 == Call( "GetNextSignalState", "", 1, 1, 0 ) then
         Call( "SendSignalMessage", 4, "", 1, 1, 0)
      end
   end
end

function OnSignalMessage( message, parameter, direction, linkIndex )

   -- Forward each message except for RESET_SIGNAL_STATE
   if ( parameter ~= "DoNotForward" and message ~= 0) then
      Call( "SendSignalMessage", message, parameter, -direction, 1, linkIndex )
   end
end

function GetSignalState( )
   return Call( "GetNextSignalState", "", 1, 1, 0 )
end


The signal object linking to this code should have
Code: Select all
<Stopping d:type="cDeltaString">eFalse</Stopping>
for a perfect solution. It would work with eTrue, but then, that object would show up in HUD and case AI to stop there.

Thanks go to Rob for persistence and improvement suggestions.
AndiS
Top Link Driver!
 
Posts: 619
Joined: Wed Apr 09, 2014 5:48 pm
Has thanked: 253 times
Been thanked: 294 times

Previous

Return to Tutorials, Guides, FAQ

Who is online

Users browsing this forum: No registered users and 1 guest