Add: [Script] Optional filter parameter to ScriptVehicleList constructor (#11663)

This commit is contained in:
Loïc Guilloux
2024-01-01 01:07:47 +01:00
committed by GitHub
parent f56a2d0f82
commit a672813bb0
6 changed files with 109 additions and 3 deletions

View File

@@ -1814,10 +1814,17 @@ function Regression::Vehicle()
print(" GetLastErrorString(): " + AIError.GetLastErrorString());
local list = AIVehicleList();
local in_depot = AIVehicleList(AIVehicle.IsInDepot);
local IsType = function(vehicle_id, type) {
return AIVehicle.GetVehicleType(vehicle_id) == type;
}
local rv_list = AIVehicleList(IsType, AIVehicle.VT_ROAD);
print("");
print("--VehicleList--");
print(" Count(): " + list.Count());
print(" InDepot Count(): " + in_depot.Count());
print(" RoadVehicle Count(): " + rv_list.Count());
list.Valuate(AIVehicle.GetLocation);
print(" Location ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {

View File

@@ -9391,6 +9391,8 @@ ERROR: IsEnd() is invalid as Begin() is never called
--VehicleList--
Count(): 5
InDepot Count(): 4
RoadVehicle Count(): 2
Location ListDump:
13 => 33417
12 => 33417