Leslie Posted May 28 Posted May 28 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?
Goetz Posted May 28 Posted May 28 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.)
Leslie Posted May 29 Author Posted May 29 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?
BahnLand Posted May 29 Posted May 29 Hallo / hello @Leslie, 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
Leslie Posted May 29 Author Posted May 29 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.
Goetz Posted May 29 Posted May 29 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)
Leslie Posted May 29 Author Posted May 29 Not speed of coupler. Vehicle has coupler: vehicle.couplers [1] Coupler connects to another vehicle: ...couplers [1] .vehicle This vehicle has speed: ...vehicle.targetSpeedAbs
Goetz Posted May 29 Posted May 29 vor 4 Minuten schrieb Leslie: Coupler connects to another vehicle: ...couplers [1] .vehicle my apologies, Leslie
Phrontistes Posted May 29 Posted May 29 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
Goetz Posted May 29 Posted May 29 (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 May 29 by Goetz
Goetz Posted May 29 Posted May 29 (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 Edited May 29 by Goetz
Phrontistes Posted May 29 Posted May 29 (edited) Since you still don't have the connected vehicle, you will surely discover .connectedCoupler at some point. Edited May 29 by Phrontistes
EASY Posted May 29 Posted May 29 (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 May 29 by EASY
Leslie Posted May 29 Author Posted May 29 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.
Leslie Posted May 29 Author Posted May 29 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?
Goetz Posted May 29 Posted May 29 (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) And check the name too. Upper case and lower case are not arbitrary Edited May 29 by Goetz picture added
Phrontistes Posted May 29 Posted May 29 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?
Leslie Posted May 29 Author Posted May 29 "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.
Leslie Posted May 29 Author Posted May 29 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?
Phrontistes Posted May 29 Posted May 29 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².
Phrontistes Posted May 29 Posted May 29 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.
Leslie Posted May 29 Author Posted May 29 "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.
EASY Posted May 29 Posted May 29 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
Leslie Posted May 29 Author Posted May 29 This is true. But how to re-place not connected vehicles to other road on changed turnouts? This usually happens only at connected vehicles.
Goetz Posted May 29 Posted May 29 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"
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now