From 5c19668fdb3c1b77439bde1968a4075ac02a2b79 Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Sat, 15 Feb 2020 11:53:31 +0000 Subject: [PATCH] Doc: [Script] Add a note about how wagon connectivity works for scripts --- bin/ai/regression/tst_regression/main.nut | 3 +++ bin/ai/regression/tst_regression/result.txt | 3 +++ src/script/api/script_vehicle.hpp | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/bin/ai/regression/tst_regression/main.nut b/bin/ai/regression/tst_regression/main.nut index 5ace44eec7..65742d71b3 100644 --- a/bin/ai/regression/tst_regression/main.nut +++ b/bin/ai/regression/tst_regression/main.nut @@ -1690,6 +1690,9 @@ function Regression::Vehicle() print(" BuildVehicle(): " + AIVehicle.BuildVehicle(10008, 9)); print(" BuildVehicle(): " + AIVehicle.BuildVehicle(10008, 27)); print(" BuildVehicle(): " + AIVehicle.BuildVehicle(10008, 27)); + print(" IsValidVehicle(17): " + AIVehicle.IsValidVehicle(17)); + print(" IsValidVehicle(18): " + AIVehicle.IsValidVehicle(18)); + print(" IsValidVehicle(19): " + AIVehicle.IsValidVehicle(19)); // 19 is immediately joined to 18 print(" MoveWagonChain(): " + AIVehicle.MoveWagonChain(18, 0, 17, 0)); print(" GetNumWagons(): " + AIVehicle.GetNumWagons(17)); print(" GetLength(): " + AIVehicle.GetLength(17)); diff --git a/bin/ai/regression/tst_regression/result.txt b/bin/ai/regression/tst_regression/result.txt index 18ae14cb7a..4cb74aaa54 100644 --- a/bin/ai/regression/tst_regression/result.txt +++ b/bin/ai/regression/tst_regression/result.txt @@ -9115,6 +9115,9 @@ ERROR: IsEnd() is invalid as Begin() is never called BuildVehicle(): 17 BuildVehicle(): 18 BuildVehicle(): 19 + IsValidVehicle(17): true + IsValidVehicle(18): true + IsValidVehicle(19): false MoveWagonChain(): true GetNumWagons(): 3 GetLength(): 24 diff --git a/src/script/api/script_vehicle.hpp b/src/script/api/script_vehicle.hpp index 4b8a4687ab..3c242d56fe 100644 --- a/src/script/api/script_vehicle.hpp +++ b/src/script/api/script_vehicle.hpp @@ -312,6 +312,10 @@ public: * @return The VehicleID of the new vehicle, or an invalid VehicleID when * it failed. Check the return value using IsValidVehicle. In test-mode * 0 is returned if it was successful; any other value indicates failure. + * @note Unlike the GUI, wagons are not automatically attached to trains, + * only to existing free wagons. This means that BuildVehicle can sometimes + * return an ID indicating success, but IsValidVehicle check will + * fail. You should use MoveWagon to attach free wagons to trains. * @note In Test Mode it means you can't assign orders yet to this vehicle, * as the vehicle isn't really built yet. Build it for real first before * assigning orders.