Detecting traffic lights status.

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
agentw4b
Traffic Manager
Traffic Manager
Posts: 160
Joined: 14 Apr 2017 15:51
Location: Czech Republic

Detecting traffic lights status.

Post by agentw4b »

Is there a command in "NoGo API" or "NoAI API" that detects the traffic lights status or the occupancy status of the track? Alternatively, if a signal can be switched.
I can not find anything :-(
Owner and admin of servers:Experimental games 01 (92.63.57.152:3979), Experimental games 02 (92.63.57.152:3879), Experimental games 03 (92.63.57.152:3779), Experimental games 04 (92.63.57.152:3679), Experimental games 05 (92.63.57.152:3579).
My heightmaps: Flat Earth Map and United nations logo
My scenarios: Game Fallout 1,2,3 Map scenario
My gamescripts: City Founder GS

User avatar
odisseus
Engineer
Engineer
Posts: 100
Joined: 01 Nov 2017 21:19

Re: Detecting traffic lights status.

Post by odisseus »

I have no idea whether it is possible to provide such API, but even if it were, this would be against the intent of the game.

The signals exist so that the trains can drive without intervention from the player, be it human or AI. Allowing the AI to take action depending on signal status and track occupancy would allow it to steer every train manually instead of relying on the pathfinder.

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9394
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Detecting traffic lights status.

Post by planetmaker »

There are no provisions to manually control signals and there is currently no intention to add such possibility (as far as I am aware).

Signal state is more a reflection of the path finder status than an input to them (even though they are also input to some degree).

HGus
Engineer
Engineer
Posts: 96
Joined: 12 May 2013 22:28
Location: Argentina

Re: Detecting traffic lights status.

Post by HGus »

You can use AITile::HasTransportType to check for crossings and AIVehicle::GetLocation to check for trains just by the road and make your RVs stop until the trains leave the inmediate area. But you cannot find out if the trains are entering or exiting the crossings and the info is only available for those owned by you. GSVehicle can work on any company.

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 3 guests