Jump to content

Empfohlene Beiträge

Geschrieben

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?

Geschrieben

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

 

 

Geschrieben

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?

Geschrieben

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

 

Geschrieben

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.

Geschrieben
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)

Geschrieben

Not speed of coupler.

Vehicle has coupler: vehicle.couplers [1]

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

This vehicle has speed: ...vehicle.targetSpeedAbs

Geschrieben
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

 

Geschrieben (bearbeitet)
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)

Bearbeitet von Goetz
Geschrieben (bearbeitet)

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

Bearbeitet von Goetz
Geschrieben (bearbeitet)

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

Bearbeitet von EASY
Geschrieben

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.

Geschrieben

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?

Geschrieben (bearbeitet)
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

 

Bearbeitet von Goetz
picture added
Geschrieben
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?

Geschrieben

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

Geschrieben

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?

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

Geschrieben

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

Geschrieben

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

Geschrieben

This is true.

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

Geschrieben
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"

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