Jump to content

Recommended Posts

Posted

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!

Posted

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

Posted (edited)

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.

Edited by Phrontistes
typo
Posted

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.

Posted

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...