Jump to content

Empfohlene Beiträge

Geschrieben

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.

modul.JPG.376ee5ae11d999caa212c7f1b4f22a83.JPG

With this developing become quite easier.

Thank you in advance!

Geschrieben

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

Geschrieben (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 von Phrontistes
typo
Geschrieben

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.

Geschrieben

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

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 erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde dich hier an.

Jetzt anmelden
×
×
  • Neu erstellen...