Building roads and TestMode

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
SummerBulb
Engineer
Engineer
Posts: 24
Joined: 06 Feb 2010 22:12

Building roads and TestMode

Post by SummerBulb »

Hi.

New to AIs.

If i want to build a road, using pathfinder.
Lets say the function that builds the road is called BuildRD();
I there a way, using TestMode, to check how much the whole thing will cost me (without building the road, of course)?

I can set the TestMode and check if the build was successful. But hoe do i get the cost?

Thanks,
Bulb.
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: Building roads and TestMode

Post by Morloth »

Hi SummerBulb,

You can use the following code:

Code: Select all

local bla = AITestMode();
local accounts = AIAccounting();

BuildRD();

local totalCost = accounts.GetCosts();
Good luck with your AI! :)
Bram
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 7 guests