Leslie Geschrieben Freitag um 13:10 Uhr Geschrieben Freitag um 13:10 Uhr At program always must start iteration when you wish to access any vehicles on route (and the trigger is not the vehicle). But most cases you need only first vehicle. Please modify current routines to get first vehicle at route. Like this: getVehiclesOn("place",firstonly(boolean)) Or: getVehicleOn() In module I suggest a markbox with label: "only first vehicle". As commands and conditions. With this developing become quite easier. Thank you in advance!
Goetz Geschrieben Freitag um 13:56 Uhr Geschrieben Freitag um 13:56 Uhr Switch to Lua, drop the iteration (you don't need it) and pick the first item from the list: local t = layout:getVehicleGroup(vehicle) t[1].couplers[1].enabled = false disables the rear coupler of the first vehicle of a train
Phrontistes Geschrieben Freitag um 15:33 Uhr Geschrieben Freitag um 15:33 Uhr (bearbeitet) And t[#t].couplers[0].enabled = false disables the front coupler of the last vehicle. And this local t=layout:getVehicleGroup(vehicle) -- First Vehicle t[1].couplers[0].enabled = t[1].couplers[0].connectedCoupler ~= nil t[1].couplers[1].enabled = t[1].couplers[1].connectedCoupler ~= nil if #t > 1 then -- Last vehicle t[#t].couplers[0].enabled = t[#t].couplers[0].connectedCoupler ~= nil t[#t].couplers[1].enabled = t[#t].couplers[1].connectedCoupler ~= nil end disables the couplers at the free ends of a vehicle group. Bearbeitet Freitag um 15:33 Uhr von Phrontistes typo
Leslie Geschrieben Freitag um 21:03 Uhr Autor Geschrieben Freitag um 21:03 Uhr Based on the advice of @Goetz the partial solution: Create a user-triggered event with parameter "Track": $("Events").variables["Truck"] = layout:getVehiclesOn(Track)[1] Then you find the first vehicle of given track on the module variable "Truck". Or nil if track is empty. You can use this event with any module or write it directly to LUA.
EASY Geschrieben Sonntag um 10:27 Uhr Geschrieben Sonntag um 10:27 Uhr Hi, Am 9.5.2025 um 23:03 schrieb Leslie: Based on the advice of Goetz the partial solution: Create a user-triggered event with parameter "Track": $("Events").variables["Truck"] = layout:getVehiclesOn(Track)[1] Then you find the first vehicle of given track on the module variable "Truck". Or nil if track is empty. You can use this event with any module or write it directly to LUA. Note: layout:getVehiclesOn() does not necessarily return the correct order of the vehicles within the train formation. layout:getVehicleGroup() returns the correct order... EASY
Phrontistes Geschrieben Sonntag um 11:01 Uhr Geschrieben Sonntag um 11:01 Uhr It's good that you pointed that out. I completely overlooked that @Leslie always uses getVehiclesOn instead of getVehicleGroup.
Empfohlene Beiträge
Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren
Du musst ein Benutzerkonto besitzen, um einen Kommentar verfassen zu können
Benutzerkonto erstellen
Neues Benutzerkonto für unsere Community erstellen.
Neues Benutzerkonto erstellenAnmelden
Du hast bereits ein Benutzerkonto? Melde dich hier an.
Jetzt anmelden