overriding railpathfinder

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
Hephi
Engineer
Engineer
Posts: 72
Joined: 25 Oct 2009 09:56
Location: Belgium

overriding railpathfinder

Post by Hephi »

Hi, I was trying to fix an error in MailAI (several years late).
When running the current version that's available it seems to be running fine at the start.
When running a slightly altered version for testing it throws an error in a part I haven't altered.

It throws 'the index MyRailPF does not exist' when running the code 'local railfinder = MyRailPF();'
When I try looking for MyRailPF() it does not exist anywhere in my .nut files.
I'm pretty sure it is some kind of altered version of the pathfinder.rail but all I have for that is one overridden method in my main.nut

import("Pathfinder.Rail", "RailPathFinder", 1);
class MyRailPathFinder extends RailPathFinder {}
function MyRailPathFinder::_Estimate(cur_tile, cur_direction, goal_tiles, self) {
local est = ::RailPathFinder._Estimate(cur_tile, cur_direction, goal_tiles, self);
return abs(est * 1.3);
}

This is all long ago, and I know I'm providing very little info above. But is there anyone who can direct me as to where to look for info on how to override railpathfinder?
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Hephi
Engineer
Engineer
Posts: 72
Joined: 25 Oct 2009 09:56
Location: Belgium

Re: overriding railpathfinder

Post by Hephi »

Found the problem, because I'm a sloppy non professional programmer my code is spaghetti with bad naming conventions, I renamed the class but forgot to check all places where it is used.

class MyRailPF extends RailPathFinder {} became class MyRailPathFinder extends RailPathFinder {}
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests