[Bug]: AI: Function::acall() does not work on some functions
Author: yangflCreated Jul 22, 2026Updated Sep 9, 2026
Version of OpenTTD
15.3
Expected result
fn.acall([this, ...]) == fn(...)
Actual result
You are not allowed to execute any DoCommand (even indirect) in your constructor, Save(), Load(), and any valuator.
Steps to reproduce
{
local test_mode = AITestMode();
local accounting = AIAccounting();
AIVehicle.BuildVehicle(depot, engine);
AILog.Info(accounting.GetCosts()); // ok
}
function GetCosts(fn, args) {
local test_mode = AITestMode();
local accounting = AIAccounting();
fn.acall(args);
return accounting.GetCosts();
}
AILog.Info(GetCosts(AIVehicle.BuildVehicle, [this, depot, engine])); // errorSource: OpenTTD/OpenTTD