Fix #10490: Allow ships to exit depots if another is not moving at the exit point...
[openttd-github.git] / src / script / api / script_vehiclelist.hpp
blobc629bc48d2a5d01eae0cea15da034c96cd5b885e
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file script_vehiclelist.hpp List all the vehicles (you own). */
10 #ifndef SCRIPT_VEHICLELIST_HPP
11 #define SCRIPT_VEHICLELIST_HPP
13 #include "script_list.hpp"
14 #include "script_vehicle.hpp"
16 /**
17 * Creates a list of vehicles of which you are the owner.
18 * @api ai game
19 * @ingroup ScriptList
21 class ScriptVehicleList : public ScriptList {
22 public:
23 #ifdef DOXYGEN_API
24 ScriptVehicleList();
26 /**
27 * Apply a filter when building the list.
28 * @param filter_function The function which will be doing the filtering.
29 * @param params The params to give to the filters (minus the first param,
30 * which is always the index-value).
31 * @note You can write your own filters and use them. Just remember that
32 * the first parameter should be the index-value, and it should return
33 * a bool.
34 * @note Example:
35 * ScriptVehicleList(ScriptVehicle.IsInDepot);
36 * function IsType(vehicle_id, type)
37 * {
38 * return ScriptVehicle.GetVehicleType(vehicle_id) == type;
39 * }
40 * ScriptVehicleList(IsType, ScriptVehicle.VT_ROAD);
42 ScriptVehicleList(void *filter_function, int params, ...);
43 #else
44 /**
45 * The constructor wrapper from Squirrel.
47 ScriptVehicleList(HSQUIRRELVM vm);
48 #endif /* DOXYGEN_API */
51 /**
52 * Creates a list of vehicles that have orders to a given station.
53 * @api ai game
54 * @ingroup ScriptList
56 class ScriptVehicleList_Station : public ScriptList {
57 public:
58 /**
59 * @param station_id The station to get the list of vehicles from, which have orders to it.
60 * @pre ScriptBaseStation::IsValidBaseStation(station_id)
62 ScriptVehicleList_Station(StationID station_id);
65 /**
66 * Creates a list of vehicles that have orders to a given depot.
67 * The list is created with a tile. If the tile is part of an airport all
68 * aircraft having a depot order on a hangar of that airport will be
69 * returned. For all other vehicle types the tile has to be a depot or
70 * an empty list will be returned.
71 * @api ai game
72 * @ingroup ScriptList
74 class ScriptVehicleList_Depot : public ScriptList {
75 public:
76 /**
77 * @param tile The tile of the depot to get the list of vehicles from, which have orders to it.
79 ScriptVehicleList_Depot(TileIndex tile);
82 /**
83 * Creates a list of vehicles that share orders.
84 * @api ai game
85 * @ingroup ScriptList
87 class ScriptVehicleList_SharedOrders : public ScriptList {
88 public:
89 /**
90 * @param vehicle_id The vehicle that the rest shared orders with.
92 ScriptVehicleList_SharedOrders(VehicleID vehicle_id);
95 /**
96 * Creates a list of vehicles that are in a group.
97 * @api ai game
98 * @ingroup ScriptList
100 class ScriptVehicleList_Group : public ScriptList {
101 public:
103 * @param group_id The ID of the group the vehicles are in.
104 * @game @pre ScriptCompanyMode::IsValid().
106 ScriptVehicleList_Group(GroupID group_id);
110 * Creates a list of vehicles that are in the default group.
111 * @api ai game
112 * @ingroup ScriptList
114 class ScriptVehicleList_DefaultGroup : public ScriptList {
115 public:
117 * @param vehicle_type The VehicleType to get the list of vehicles for.
118 * @game @pre ScriptCompanyMode::IsValid().
120 ScriptVehicleList_DefaultGroup(ScriptVehicle::VehicleType vehicle_type);
123 #endif /* SCRIPT_VEHICLELIST_HPP */