Jump to content

Recommended Posts

Posted

I wish a method to exchange the speeds of 2 vehicle at collision and then disconnect them.

Is there a solution for this and what kind of property settings needed for?

Posted

There is no collision detection event, @Leslie.
We have no means to respond to a collision.

Actually, there are no collisions as such. 
With active couplers, vehicles slow on approach and stop when they couple.
With inactive couplers, the stop short and avoid collision (when automatic breaking is active, as it should be.)

 

 

Posted

I know, not such event. I must get state other way.

But the question is the method of speed excange. If 2 vehicles is moving each other and first has less targetspeed than last. This is real case.

I have tried but failed. Have anybody a solution?

Posted

Hallo / hello @Leslie,

Geschwindigkeitsanpassung.thumb.jpg.0eed592b8663e7b431609d899abb7378.jpg

aktiviere die beiden markierten Buttons im Eigenschaftsfester des Fahrzeugs, um die Geschwindigkeits-Anpassung an das vorausfahrende Fahrzeug zu aktivieren.
Activate the two highlighted buttons in the vehicle's properties window to activate the speed adjustment to the vehicle in front.

Viele Grüße / many greetings
BahnLand

 

Posted

I am far away from this.

Current routine:

if vehicle.couplers[1] ~= nil then
local v = vehicle.couplers[1].vehicle.targetSpeedAbs
vehicle.couplers[1].vehicle.targetSpeedAbs = vehicle.targetSpeedAbs
vehicle.targetSpeedAbs = v
end

 

Piti, still does not work. I hoped somebody can help otherwise this shall be a long debugging.

Posted
vor 15 Minuten schrieb Leslie:

local v = vehicle.couplers[1].vehicle.targetSpeedAbs

Why would you assume that the coupler has a speed?
The vehicle does!

local v = vehicle.targetSpeedAbs

The vehicle has a coupler, which you may check as a condition (as you do)
And the vehicle has a speed (which you may read and store in a local variable)

Posted

Not speed of coupler.

Vehicle has coupler: vehicle.couplers [1]

Coupler connects to another vehicle: ...couplers [1] .vehicle

This vehicle has speed: ...vehicle.targetSpeedAbs

Posted
vor 4 Minuten schrieb Leslie:

Coupler connects to another vehicle: ...couplers [1] .vehicle

my apologies, Leslie

Posted
vor 2 Minuten schrieb Leslie:

Coupler connects to another vehicle: ...couplers [1] .vehicle

but this is evidently the same vehicle

vor 32 Minuten schrieb Leslie:

local v = vehicle.couplers[1].vehicle.targetSpeedAbs

 

Posted (edited)
vor 9 Minuten schrieb Phrontistes:

but this is evidently the same vehicle

no, it's not (I made the same mistake)
The property couplers[1].vehicle is not identical with the object vehicle

Es ist doch dasselbe Fahrzeug. Sorry!

"enthält eine Referenz zu dem Fahrzeug, zu dem die Kupplung gehört"

(nicht, wie ich flüchtig interpretiert hatte, dem Fahrzeug, das an der Kupplung hängt)

Edited by Goetz
Posted (edited)

I found a mistake, @Leslie

The condition is incomplete!

It should be

if vehicle.couplers[1].enabled == true then

and as @Phrontistes rightly pointed out:
couplers[1].vehicle references the vehicle which owns the coupler, not the vehicle connected at the coupler

couplervehicle.thumb.jpg.b2cd32165b7ee43b1b8b24c82e2668b3.jpg

Edited by Goetz
Posted (edited)

Hi,

vor 19 Stunden schrieb Goetz:

There is no collision detection event,

vor 10 Stunden schrieb Leslie:

I know, not such event.

How do you want to detect that a collision has taken place?

EASY

Edited by EASY
Posted

Collision detection at any other event, eg. enter track. When vehicles connected then collison occured.

This case one pulls another. The problem is: I do not want to connect them! So couplers disabled.

But they are also connected: eg. one pulls another among turnouts like connected vehicles. Check this if you want.

Also they not connected in level of program because couplers are nil.

I wish to exchange speeds then auto disconnect. This rutine:

if vehicle.couplers[1].connectedCoupler ~= nil then
local v = vehicle.couplers[1].connectedCoupler.vehicle.targetSpeedAbs
vehicle.couplers[1].connectedCoupler.vehicle.targetSpeedAbs = vehicle.targetSpeedAbs
vehicle.targetSpeedAbs = v
end

seems work some time.

Posted

Oher problem: if $("camera").link is vehicle then command $("Camera").link.autoDeceleration = true causes error property autoDeceleration does not exist.

How to set autoDeceleration in LUA on linked vehicles?

Posted (edited)
vor 34 Minuten schrieb Leslie:

$("Camera").link.autoDeceleration = true

works just fine when I try it.

You may want to verify that the camera is linked to the vehicle (chain icon in top menu bar)

verknpfen.jpg.f65d741919b6d013f34494189f9ee3ba.jpg

And check the name too. Upper case and lower case are not arbitrary

 

Edited by Goetz
picture added
Posted
vor einer Stunde schrieb Leslie:

vehicle.couplers[1].connectedCoupler.vehicle.targetSpeedAbs = vehicle.targetSpeedAbs

is valid only if vehicle.couplers[1].connectedCoupler.vehicle has an engine and engine is started.

vor einer Stunde schrieb Leslie:

local v = vehicle.couplers[1].connectedCoupler.vehicle.targetSpeedAbs
...
vehicle.targetSpeedAbs = v

What are these two lines for?

Posted

"camera is linked to the vehicle"

Yes, it is automatic, not hand-made. But some cases camera connected to a switch which has no engine, totally no acceleration. So I modified condition to check this switch, this works.

Posted

What are these two lines for?

Exchange speeds thru local v.

 

I tried advice of Bahnland, all cars got smooth decceleration. This solves collision but causes other problem: vehicles must enter to turnouts to automatic change. At smooth decceleration sometimes lines too short, vehicle stops before reach turnout and hangs up. Is there a method to avoid car collision and also drive to end of roads?

Posted
vor 35 Minuten schrieb Leslie:

But some cases camera connected to a switch which has no engine, totally no acceleration.

Automatic deceleration / acceleration only works with a vehicle which has an startet engine.

vor 31 Minuten schrieb Leslie:

there a method to avoid car collision and also drive to end of roads?

You have to try out the appropriate acceleration / deceleration in m/s².

Posted
vor 39 Minuten schrieb Leslie:

Exchange speeds thru local v.

Okay, but I don't understand the whole thing anyway: coupled vehicles cannot have different speeds.

Posted

"coupled vehicles"

Who says this?

All my force I struggle for not to connect them! They are all individuals with different speeds! This may cause collision!

But here is the solution: vehicle plays smooth usually. This avoids collision at long roads. But if stops, it changes to hard way which allows manoeuvres may switch turnouts to solve the problem.

Posted

Hi,

vor 24 Minuten schrieb Leslie:

"coupled vehicles"

Who says this?

... why this????

vor 3 Stunden schrieb Leslie:

if vehicle.couplers[1].connectedCoupler ~= nil then

...  vehicle.couplers[1].connectedCoupler is always nil when vehicles not coupled!

EASY

Posted

This is true.

But how to re-place not connected vehicles to other road on changed turnouts? This usually happens only at connected vehicles.

Posted
vor 3 Minuten schrieb Leslie:

turnouts ... connected vehicles

Cars may come very close to each other at turnouts. But they don't couple (because their couplers are not active by default)
So even when two cars look like they are connected, the condition will still say "nil"

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...