This file is part of the AI library cEngineLib Copyright (C) 2013 krinn. @che z.comMore...
Classes | |
class | Infos |
The class to create object that could be use by cEngineLib.GetBestEngine() ie: local myobject = cEngineLib.Infos(); myobject.engine_id = 34; local result = cEngineLib.GetBestEngine(myobject);. More... |
Public Member Functions | |
function | GetAuthor () |
function | GetName () |
function | GetShortName () |
function | GetDescription () |
function | GetVersion () |
function | GetAPIVersion () |
function | GetDate () |
function | CreateInstance () |
function | GetURL () |
function | GetCategory () |
function | LearnEngineFromDepot (depotID, engineID) |
That function will let the library learn engines by creating vehicles and testing them (and sell them), so this function use @VehicleWagonCompatibilityTest Because this function use money , you may prefer handle the learning yourself using ... | |
function | LearnEngineFromVehicle (vehicleID, all_type) |
That function will let the library learn engines from existing vehicles This function use an existing vehicle to discover properties of engines in it. | |
function | VehicleUpdateEngineProperties (veh_id) |
That's the library key function, this update properties of engine by looking at the vehicle. | |
function | GetBestEngine (object, filter) |
This function returns the best engine to use (or couple engine loco+wagon) using the filter you wish. | |
function | EngineFilter (engine_list, cargo_id, road_type, engine_id, bypass) |
Change an ailist to filter out engine (so watchout what ailist you gives, its content will be change) Default filters are : remove blacklist engine, remove unbuildable, remove incompatible engine, other filters are optionals. | |
function | VehicleCreate (depot, engine_id, cargo_id=-1) |
Create the vehicle at depot, upto you to add orders... | |
function | GetLength (engine_id, cargo_id=-1) |
Get the length of an engine when refit to handle cargo_id type. | |
function | GetCapacity (engine_id, cargo_id=-1) |
Get the capacity of an engine for that cargo type. | |
function | VehicleGetWeight (vehicle_id, empty=true) |
Get the total weight of a vehicle : only for rail vehicle. | |
function | VehicleGetMaxTractiveEffort (vehicle_id) |
Get the total max tractive effort a vehicle handle (summing all engines values), only for rail and road vehicle. | |
function | VehicleGetMaxPower (vehicle_id, KW=false) |
Get the total power of a vehicle (summing all engines values), only for rail and road vehicle. | |
function | VehicleGetRailTypeUse (vehicle_id) |
Get the railtype the vehicle is running on (if you run a vehicle on different railtype, the answer will depend on which ones it was running when checked) | |
function | VehicleGetMaxSpeed (vehicle_id) |
Return the maximum speed the vehicle can do with its engine, railtype and wagons in use. | |
function | IsLocomotive (engine_id) |
Check if an engine is a locomotive. | |
function | VehicleIsMultiEngine (vehicle_id) |
Check if a train use multi locomotive or is multihead if the API support the function. | |
function | VehicleGetNumberOfLocomotive (vehicle_id) |
Get the number of locomotive a vehicle have: note that two heads engine will be count as two locomotives! | |
function | VehicleLackPower (vehicle_id, aim_speed=0) |
Look at the given vehicle, get its first loco engine and return true if you lack enough power (for original acceleration model) or tractive effort (for realistic model) to run that vehicle at low speed on hills (at ~15% of its maxspeed) It handle the game setting "train_slope_steepness" (http://wiki.openttd.org/Train_slope_steepness) It handle the "train_accelaration_model", increase x2 the aim speed when original model is use. | |
function | VehicleGetNumberOfWagons (vehicle_id) |
Get the number of wagons a vehicle have (excluding loco engine) | |
function | VehicleGetRandomWagon (vehicle_id) |
Get the position of a random wagon in the train. | |
function | IncompatibleEngine (engine_one, engine_two) |
Mark engine_one and engine_two not compatible with each other This could only be use with trains. | |
function | CompatibleEngine (engine_one, engine_two) |
Mark engine_one and engine_two compatible with each other This could only be use with trains. | |
function | AreEngineCompatible (engine, compare_engine) |
Check if engine1 is usable with engine2. | |
function | VehicleWagonCompatibilityTest (vehicleID, wagonID) |
Test compatibilty of a wagon engine with the vehicle. | |
function | CanPullCargo (engine_id, cargo_id, bypass=false) |
Check if the engine can pull a wagon with the given cargo. | |
function | IsEngineBlacklist (engine_id) |
Return if that engine is blacklist or not. | |
function | BlacklistEngine (engine_id) |
Add an engine to the blacklist. | |
function | IsDepotTile (tile) |
Check if the tile is a depot. | |
function | GetDepotType (tile) |
Get the type of depot found at tile. | |
function | VehicleIsGoingToStopInDepot (vehicle_id) |
Answer if the current order (even not in its list) is going to depot and if it will stop there. | |
function | VehicleOrderSkipCurrent (vehicle_id) |
Skip the current order in vehicle, it doesn't check any conditionnal orders and just jump to next order in position. | |
function | VehicleOrderClear (vehicle_id) |
Unshare and clear the order list of a vehicle. | |
function | RailTypeGetFastestType (engineID=-1) |
This will browse railtype and return the railtype that can reach the fastest speed or the fastest railtype a given engine could use. | |
function | RailTypeGetFastestTypeForCargo (cargoID, bypass=false) |
This will browse railtype and return the railtype that can reach the fastest speed to pull a cargo Even if you can easy get the fastest railtype, it is harder to actually find one that is usable with a cargo. | |
function | RailTypeGetSpeed (RT=-1) |
Return the speed of the given railtype, so to get the speed of the current fastest railtype, cEngineLib.RailTypeGetSpeed(cEngineLib.RailTypeGetFastestType());. | |
function | VehicleRestrictLength (vehicle_id, max_length) |
This restrict a train length to met max_length, selling wagons only to met it (so a train, stopped, in a depot), the vehicle size may still not met the length if it is bigger because of its loco(s) length in it. | |
function | GetMaxWagons (engines, max_length, cargo_id=-1) |
Get the number of wagons we could add to stay below max_length. | |
function | SetAPIErrorHandling (output) |
Enable or disable errors message. | |
function | GetAPIError () |
Get the last error string the API report. | |
function | SetMoneyCallBack (money_func) |
Set the API to use your money callback function, a function run by the API when it need to get money The callback function will be called with "amount" as parameter, ie: cEngineLib.SetMoneyCallBack(myAI.MoneyGiver); with <function myAI::MoneyGiver(amount) { // grant the money }. | |
function | EngineCacheInit () |
This will browse engines so they are all added to the engine database, faster next access to any engine properties. | |
function | DirtyEngineCache (eng_type) |
This will dirty the cache of eng_type, forcing next access to the cache to sent fresh infos. | |
function | GetEngineList (eng_type) |
Return a cache AIList of engines of the type "eng_type". | |
function | DumpLibStats () |
The lib will output to the console some stats about itself, that's of course a debug feature, but it might help you. | |
function | Engine_Stats (engine_id) |
function | ErrorReport (error) |
function | ErrorReport_NORAILTRACK () |
function | ErrorReport_INVALIDVEHICLE (id) |
function | ErrorReport_INVALIDCARGO (id) |
function | SetUsuability (engine_one, engine_two, flags) |
function | IsCoupleTested (engine_one, engine_two) |
function | SetRailTypeSpeed (engineID) |
function | Load (e_id) |
function | Save () |
function | EngineIsKnown (engine_id) |
function | GetKnownLevel (engine_id) |
function | Filter_EngineTrain (engine_list, object) |
function | Filter_EngineGeneric (engine_list, object) |
function | GetCallbackResult (callback, callback_param) |
function | EngineToName (engID) |
function | CheckEngineObject (eo) |
function | GetMoney (amount) |
Public Attributes | |
engine_id = null | |
id of the engine | |
cargo_capacity = null | |
capacity per cargo item=cargoID, value=capacity when refit | |
cargo_length = null | |
that's the length of a vehicle depending on its current cargo setting | |
cargo_pull = null | |
only for locos, cargobits it is able to pull. | |
is_known = null | |
0: never seen that engine, 1: basic tests made 2: loco tests made | |
usuability = null | |
compatibility list of wagons & locos, item=the other engineID value=cargobits 1 compatible, 0 incompatible with that cargo |
Static Public Attributes | |
static | VT_RAIL = AIVehicle.VT_RAIL |
static | VT_ROAD = AIVehicle.VT_ROAD |
static | VT_WATER = AIVehicle.VT_WATER |
static | VT_AIR = AIVehicle.VT_AIR |
static | VT_RAIL_LOCO = AIVehicle.VT_AIR + 1 |
static | VT_RAIL_WAGON = AIVehicle.VT_AIR + 2 |
static | _cel_ebase = {} |
static | _cel_blacklist = AIList() |
our base where engines are store | |
static | _cel_RT = AIList() |
the blacklist engine | |
static | _cel_config = "", null] |
hold configuration options and error message, you have functions to alter that. | |
static | _cel_cache = [null, null, null, null, null, null] |
we cache enginelist result here |
This file is part of the AI library cEngineLib Copyright (C) 2013 krinn. @che z.com
cEngineLib 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; either version 2 of the License, or any later version.
cEngineLib 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. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this AI Library. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. A library with helpers for engine and vehicle handling.
function cEngineLib::AreEngineCompatible | ( | engine | , |
compare_engine | |||
) |
Check if engine1 is usable with engine2.
For trains/wagons only. It is inside the default filter for trains, but your custom filter better use it too.
engine | engine id of the first engine |
compare_engine | engine id of the second engine |
function cEngineLib::BlacklistEngine | ( | engine_id | ) |
Add an engine to the blacklist.
engine_id | The engine to get blacklist |
function cEngineLib::CanPullCargo | ( | engine_id | , |
cargo_id | , | ||
bypass | = false |
||
) |
Check if the engine can pull a wagon with the given cargo.
Exactly the same as AIEngine.CanPullCargo if the bypass is set to false The ai_special_flag (nfo property 08) for newGRF is set if an engine can pull a cargo or not. But the newGRF can also allow/disallow what couple cargo/engine you are allowed to use. So, if the newGRF didn't disallow cargo/engine couple, but have its ai_special_flag set to disallow that, we could ignore it and pull the cargo we wish (as long as some compatible wagons exist to carry it). That's what the bypass param is for. The trick to get the answer: if the loco can use wagonX and wagonX can be refit to potatoes, then loco is able to pull potatoes... In order to know if wagonX can be use with that loco you need to test that with So until the loco has been test, the result is the one from AIEngine.CanPullCargo.
engine_id | The engine to check |
cargo_id | The cargo to check |
bypass | Set to false to respect newGRF author wishes, set it to true to allow bypassing the ai_special_flag |
function cEngineLib::CompatibleEngine | ( | engine_one | , |
engine_two | |||
) |
Mark engine_one and engine_two compatible with each other This could only be use with trains.
Use in
engine_one | engine id of the first engine |
engine_two | engine id of the second engine |
function cEngineLib::DirtyEngineCache | ( | eng_type | ) |
This will dirty the cache of eng_type, forcing next access to the cache to sent fresh infos.
The cache itself has a 7 openttd days lifetime ; but in case you wish a fresh list. The lib dirty the cache also when a new engine is found in a vehicle (and not because of the event)
eng_type | The engine type to dirty, it could be AIVehicle.VT_RAIL, AIVehicle.VT_ROAD, AIVehicle.VT_WATER or AIVehicle.VT_AIR |
function cEngineLib::EngineCacheInit | ( | ) |
This will browse engines so they are all added to the engine database, faster next access to any engine properties.
If you want use this, it should be called early in your AI, else its usage will get poorer with time. It now also use
function cEngineLib::EngineFilter | ( | engine_list | , |
cargo_id | , | ||
road_type | , | ||
engine_id | , | ||
bypass | |||
) |
Change an ailist to filter out engine (so watchout what ailist you gives, its content will be change)
Default filters are : remove blacklist engine, remove unbuildable, remove incompatible engine, other filters are optionals.
engine_list | an ailist of engine id |
cargo_id | if -1 don't filter, if set, filter engines that cannot be refit to use that cargo (or pull other engines using that cargo) |
road_type | : if -1 don't filter, if set, filter engines that are limit (by the roadtype, railtrack type or airport type), see object.engine_roadtype for posssible values. |
engine_id | : if -1 don't filter, if it's a wagon filter out locos that cannot pull it, if it's a loco filter out wagons that loco cannot pull |
bypass | : alter the cargo & train filter decision : see bypass value for more |
function cEngineLib::GetAPIError | ( | ) |
Get the last error string the API report.
function cEngineLib::GetBestEngine | ( | object | , |
filter | |||
) |
This function returns the best engine to use (or couple engine loco+wagon) using the filter you wish.
If you don't provide a filter it will use its own internal one, that is basic, but functional and should gives not bad result. The accuracy of the result depend on the limits you put yourself in the query, but also if the vehicle has been create and test by the lib. If you gives it a real depot, it will run (limit to the engine it think is the best) and loop to find if it's still the best one once it get test, so even it limit to one engine only, it can feed it one by one until it get a stable result. As this function may use your money, make sure the AI have enough money to buy stuff. See
object | Here's the different options :
|
object.engine_type : if depot == -1 this must be set as the AIVehicle.VehicleType of vehicle you want the query to be done.
for VT_WATER: it's not use.
filter | A function that will be called to apply your own filter and heuristic on the engine list. If null a private function will be used. The function must be : function myfilter(AIList, object) For VT_RAIL the filter will be called with two different list, 1 for locomotive, and 2nd for the wagons. So be sure to check if AIEngine.IsWagon(object.engine_id) or any engine in the list you get, to see if your filter is working on a loco or a wagon. |
function cEngineLib::GetCapacity | ( | engine_id | , |
cargo_id | = -1 |
||
) |
Get the capacity of an engine for that cargo type.
Accuracy depend on
engine_id | The engine to get the capacity of |
cargo_id | If -1, it's the current refit cargo, else the cargo id to get the capacity for. |
function cEngineLib::GetDepotType | ( | tile | ) |
Get the type of depot found at tile.
tile | a valid tile, should be a tile with a depot |
function cEngineLib::GetEngineList | ( | eng_type | ) |
Return a cache AIList of engines of the type "eng_type".
Faster access to the very same list and lesser this effect http://bugs.openttd.org/task/6213 as you will work on a shorter list. Note that the lists are stock lists of engines EXCEPT blacklist engines that are remove from it (but it still include non buildable engine).
eng_type | It could of AIVehicle.VT_RAIL, AIVehicle.VT_ROAD, AIVehicle.VT_WATER or AIVehicle.VT_AIR. But you can also use the special cEngineLib.VT_RAIL_LOCO to get only loco engine, or cEngineLib.VT_RAIL_WAGON to get only wagon engine. This should replace occurances of AIEngineList() in your code. To ease handling AIVehicle.VT_ have their cEngineLib.VT_ equivalent. |
function cEngineLib::GetLength | ( | engine_id | , |
cargo_id | = -1 |
||
) |
Get the length of an engine when refit to handle cargo_id type.
Accuracy depend on
engine_id | the engine id to query |
cargo_id | the length of the engine when refit to that cargo, if -1 the length of the engine with its default cargo |
function cEngineLib::GetMaxWagons | ( | engines | , |
max_length | , | ||
cargo_id | = -1 |
||
) |
Get the number of wagons we could add to stay below max_length.
This will return inacurate results or error if the wagon or loco was never built.
engines | an array with [0] the loco engine, and [1] the wagon engine. Accept also the array return by GetBestEngine function |
max_length | The length to match : don't forget to x16 it if you aim a tile length: ie: limit to 3 tiles, max_length = 3*16 |
cargo_id | the cargo the wagon will use (-1 for default wagon size, because wagon size can change depending on the cargo use). |
function cEngineLib::IncompatibleEngine | ( | engine_one | , |
engine_two | |||
) |
Mark engine_one and engine_two not compatible with each other This could only be use with trains.
Use in
engine_one | engine id of the first engine |
engine_two | engine id of the second engine |
|
inline |
Check if the tile is a depot.
tile | a valid tile |
function cEngineLib::IsEngineBlacklist | ( | engine_id | ) |
Return if that engine is blacklist or not.
The lib itself doesn't need to blacklist any engines (yet).
engine_id | The engine to get check |
function cEngineLib::IsLocomotive | ( | engine_id | ) |
Check if an engine is a locomotive.
engine_id | the engine to check |
function cEngineLib::LearnEngineFromDepot | ( | depotID | , |
engineID | |||
) |
That function will let the library learn engines by creating vehicles and testing them (and sell them), so this function use @VehicleWagonCompatibilityTest
Because this function use money , you may prefer handle the learning yourself using ...
But this function really automates everything for you. The learning is done at the given depot and it will create all engines it could with the money you have (and sell them fast to get your money back), keep in mind, that a rail depot is limited by its railtype, so you can't build (and learn) a maglev engine in a non maglev depot (look at engine == -2 for that). Because this function do all the job, the accuracy of all other functions of the lib will goes upto 100% Unlike VehicleUpdateEngineProperties, this function also check compatibility of locos and wagons, making "bypass" usage 100% accurate.
depotID | a valid depot of any type (an airport is a depot) |
engineID | if a valid engineID it will test that engine only (but also other known engines for new wagons), giving 100% accuracy result for this engine. if -1 it will test all engines from that depot. This increase accuracy to 100% on all engines of that depot type ; except VT_RAIL that need more. |
function cEngineLib::LearnEngineFromVehicle | ( | vehicleID | , |
all_type | |||
) |
That function will let the library learn engines from existing vehicles
This function use an existing vehicle to discover properties of engines in it.
It is similar and actually do exactly the same as on all vehicles type except rails as this function will also fill the compatibility of engine while the other cannot. So it use what was previously create to learn from it. If it find a depot it will called with the engineID taken from that vehicle. Because it could be use with more than one vehicle, but also more than one vehicle type, it can learn from all vehicles in one go. Making it a good helper when your AI is loading a game and the lib can learn from what was create previously.
vehicleID | if it's a valid vehicleID it will learn only from that vehicle |
all_type | if vehicleID is invalid only, all vehicles from the AIVehicle.VehicleType type will be check. With AIVehicle.VT_INVALID all vehicles of any type. |
function cEngineLib::RailTypeGetFastestType | ( | engineID | = -1 | ) |
This will browse railtype and return the railtype that can reach the fastest speed or the fastest railtype a given engine could use.
engineID | the engineID to get its best railtype to use with it, if -1 get the current fastest railtype |
function cEngineLib::RailTypeGetFastestTypeForCargo | ( | cargoID | , |
bypass | = false |
||
) |
This will browse railtype and return the railtype that can reach the fastest speed to pull a cargo Even if you can easy get the fastest railtype, it is harder to actually find one that is usable with a cargo.
If you have no train able to pull it, or no wagon able to be refit to it with that railtype, the fastest railtype is finally not usable to handle this cargo. So the return answer from this function is really the fastest railtrack type with a loco and wagon that exists and that you could use with that cargo, and not simply the fastest railtrack type. It's accuracy depend on ; so range from 0% when bypass is enable and no loco has been test, to 100% if tests were made. And without enabling bypass, its accuracy depend on AIEngine.CanPullCargo that is 0% as it will never answer if the loco have a real wagon that could be refit to pull that cargo.
cargoID | the cargoID to get the railtype with a train able to pull that cargo and a compatible wagon with that loco, refitable to handle that cargo. |
bypass | enable/disable it, see |
function cEngineLib::RailTypeGetSpeed | ( | RT | = -1 | ) |
Return the speed of the given railtype, so to get the speed of the current fastest railtype, cEngineLib.RailTypeGetSpeed(cEngineLib.RailTypeGetFastestType());.
RT | The RailType to get the speed, if -1 we will return the fastest one. |
function cEngineLib::SetAPIErrorHandling | ( | output | ) |
Enable or disable errors message.
Those are only errors at using the API, not errors report by the NOAI API
output | True and the API will output its errors messages. False to disable this. You can still get the last error with GetAPIError |
function cEngineLib::SetMoneyCallBack | ( | money_func | ) |
Set the API to use your money callback function, a function run by the API when it need to get money The callback function will be called with "amount" as parameter, ie: cEngineLib.SetMoneyCallBack(myAI.MoneyGiver); with <function myAI::MoneyGiver(amount) { // grant the money }.
money_func | A valid function from your AI that should raise your account to to the wanted "amount" of money |
function cEngineLib::VehicleCreate | ( | depot | , |
engine_id | , | ||
cargo_id | = -1 |
||
) |
Create the vehicle at depot, upto you to add orders...
It will also refit the vehicle to the given cargo. As this function use your money, make sure the AI have enough money to buy stuff. See This function use limit to the vehicle you are creating, so it allow the lib to learn from each creation you do.
depot | a depot to use to create the vehicle |
engine_id | the engine to create the vehicle |
cargo_id | if set to -1 you get just the vehicle, otherwise the engine will be refit to handle the cargo (if possible) |
function cEngineLib::VehicleGetMaxPower | ( | vehicle_id | , |
KW | = false |
||
) |
Get the total power of a vehicle (summing all engines values), only for rail and road vehicle.
vehicle_id | The vehicle id |
KW | Per default the function return power in HP (like the AI API), if set to true, you will get the power in KW and the return value will be a float number. |
function cEngineLib::VehicleGetMaxSpeed | ( | vehicle_id | ) |
Return the maximum speed the vehicle can do with its engine, railtype and wagons in use.
However it doesn't check if the engine has enough power to actually reach that limit. It takes the setting "wagon_speed_limits" (see http://wiki.openttd.org/Wagon_speed_limits) and the railtype limit.
vehicle_id | The vehicle id to get its maximum speed. If the vehicle is not of AIVehicle.VT_RAIL it return the result of AIEngine.GetMaxSpeed |
function cEngineLib::VehicleGetMaxTractiveEffort | ( | vehicle_id | ) |
Get the total max tractive effort a vehicle handle (summing all engines values), only for rail and road vehicle.
vehicle_id | The vehicle id of a rail or road vehicle |
function cEngineLib::VehicleGetNumberOfLocomotive | ( | vehicle_id | ) |
Get the number of locomotive a vehicle have: note that two heads engine will be count as two locomotives!
vehicle_id | the vehicle to check, must be a rail vehicle |
function cEngineLib::VehicleGetNumberOfWagons | ( | vehicle_id | ) |
Get the number of wagons a vehicle have (excluding loco engine)
vehicle_id | the vehicle to check, must be a rail vehicle |
function cEngineLib::VehicleGetRailTypeUse | ( | vehicle_id | ) |
Get the railtype the vehicle is running on (if you run a vehicle on different railtype, the answer will depend on which ones it was running when checked)
vehicle_id | The vehicle id to get the RailType in use |
function cEngineLib::VehicleGetRandomWagon | ( | vehicle_id | ) |
Get the position of a random wagon in the train.
vehicle_id | the vehicle to check, must be a rail vehicle |
function cEngineLib::VehicleGetWeight | ( | vehicle_id | , |
empty | = true |
||
) |
Get the total weight of a vehicle : only for rail vehicle.
The function takes freight_trains setting and if the cargo is freight to calc the weight. See: http://wiki.openttd.org/Freight_trains
vehicle_id | The vehicle id of the vehicle to calc its total weight |
vehicle_id | An array with [loco engine, number of locos, wagon engine, number of wagons], so you could get what a non existing vehicle weight will be after creation. Set "number" to 0 to not pass a loco or wagon engine but array must be of size 4. |
empty | true to get the total weight when empty, false to get the total weight when full (and this include filling loco with cargo if loco handle some) |
function cEngineLib::VehicleIsGoingToStopInDepot | ( | vehicle_id | ) |
Answer if the current order (even not in its list) is going to depot and if it will stop there.
Servicing at depot is not stopping at it.
vehicle_id | the vehicle to check |
function cEngineLib::VehicleIsMultiEngine | ( | vehicle_id | ) |
Check if a train use multi locomotive or is multihead if the API support the function.
vehicle_id | the vehicle to check |
function cEngineLib::VehicleLackPower | ( | vehicle_id | , |
aim_speed | = 0 |
||
) |
Look at the given vehicle, get its first loco engine and return true if you lack enough power (for original acceleration model) or tractive effort (for realistic model) to run that vehicle at low speed on hills (at ~15% of its maxspeed) It handle the game setting "train_slope_steepness" (http://wiki.openttd.org/Train_slope_steepness) It handle the "train_accelaration_model", increase x2 the aim speed when original model is use.
(http://wiki.openttd.org/Realistic_acceleration) Even its accuracy isn't that bad, don't take its "true" answer as-is but keep some limit, To simplify the example, if you need 1000hp to pull 5 wagons and use a loco with 100hp, it would then return true until you use 10 locos, not really something usable.
vehicle_id | The vehicle id of a rail vehicle |
aim_speed | The calc are base on a train ability to aim a certain mimimum speed when climbing with its load, per default (0) the aim_speed will be 15% of maximum speed of the train engine (and a non-alterable minimum of 15spd). You can pass your own custom aim_speed to use. |
function cEngineLib::VehicleOrderClear | ( | vehicle_id | ) |
Unshare and clear the order list of a vehicle.
vehicle_id | the vehicle to work on |
function cEngineLib::VehicleOrderSkipCurrent | ( | vehicle_id | ) |
Skip the current order in vehicle, it doesn't check any conditionnal orders and just jump to next order in position.
If order was last, it jump to order 0
vehicle_id | the vehicle to skip current order |
function cEngineLib::VehicleRestrictLength | ( | vehicle_id | , |
max_length | |||
) |
This restrict a train length to met max_length, selling wagons only to met it (so a train, stopped, in a depot), the vehicle size may still not met the length if it is bigger because of its loco(s) length in it.
vehicle_id | A train with wagons you want to limit its length |
max_length | The length to match : don't forget to x16 it if you aim a tile length: ie: limit to 3 tiles, max_length = 3*16 |
function cEngineLib::VehicleUpdateEngineProperties | ( | veh_id | ) |
That's the library key function, this update properties of engine by looking at the vehicle.
This get enough information to get 100% accuracy (but only for this engine) on any vehicle type except rail, that need another step see This function should be called after a vehicle creation, so the base is filled with its values,
veh_id | a valid vehicle_id that we will inspect to get informations about its engine |
function cEngineLib::VehicleWagonCompatibilityTest | ( | vehicleID | , |
wagonID | |||
) |
Test compatibilty of a wagon engine with the vehicle.
For rails vehicle only. This autofill compatibilty state of both engines.
vehicleID | a valid vehicle, stopped in a depot, with a locomotive in it |
wagonID | the engine wagon type to test. |
|
static |
hold configuration options and error message, you have functions to alter that.
|
static |
the blacklist engine
item = the railtype, value = maximum speed doable
cEngineLib::cargo_pull = null |
only for locos, cargobits it is able to pull.