changing events for a particular loco

Awatar użytkownika
robs on the job
Posty: 19
Rejestracja: 16 paź 2009, 13:37

changing events for a particular loco

Post autor: robs on the job » 15 cze 2011, 20:53

Hi, is it possible to change one locos speed when in a block when in auto run? for example I have a loco that has trouble on certain parts of my layout. and I thought i could change the event in that block (6) to increase the speed of that particular loco (M7),I named the loco in event and set it to the increased speed and that works perfect but when i use the auto run for another loco when it gets to that block(6) it makes the M7 speed off even though it is not in that block and is not defined to any block :!: So is there a way to set a locos own speed adjustments in a particular block to help it if it struggles on a certain part of the track within a block. :?: or do I have to create a different auto run for every loco. that I wish to have different events :?:
Rob the man who knows nothing about anything....I know!!! no I dont!

Awatar użytkownika
gbbsoft
Admin
Posty: 1533
Rejestracja: 09 lip 2008, 23:19
System DCC: Lenz + Roco

Re: changing events for a particular loco

Post autor: gbbsoft » 15 cze 2011, 21:44

I think it is possible.

First remark: normally block event are independent of autoruns, so if you create second autorun, it doesn't change block event.

The idea is to change block event in this way that for train M7 event doest other operation then for other trains.
To do it you should edit block6 event and add 'IfElseActivity'. This activity create two branches of event execution. Every branch has Condition. On first branch in Condition you should create Expression:

this.ActiveTrain.Name == "M7"

on second branch other condition expression:

this.ActiveTrain.Name != "M7"

This causes thet first branch will be executed for M7 train in block but second branch for others trains.

In first branch you should put change of M7 speed.

PS. I thing you cound send to me your current .plansza file and I will help you with create 'IfElseActivity' or you can try yourself
Załączniki
IfElseActivity.JPG

Awatar użytkownika
robs on the job
Posty: 19
Rejestracja: 16 paź 2009, 13:37

Re: changing events for a particular loco

Post autor: robs on the job » 16 cze 2011, 15:49

Hi ive sent you my planza file via email as forum would not allow it to upload.
Thanks
Rob :)
Rob the man who knows nothing about anything....I know!!! no I dont!

Awatar użytkownika
gbbsoft
Admin
Posty: 1533
Rejestracja: 09 lip 2008, 23:19
System DCC: Lenz + Roco

Re: changing events for a particular loco

Post autor: gbbsoft » 16 cze 2011, 16:47

Procedure how put if-else tool to workflow:

1. drag IfElse tool from toolbox to workflow
IfElse01.jpg
2. select left 'ifElseBranchActivity1'
IfElse02.jpg
3. On right panel on property 'Condition' select 'Declarative Rule' (and expand 'Condition')
IfElse03.jpg
4. select 'Condition Name' and press '...' button to enter form to define all condition on this workflow (not only this one)
IfElse04.jpg
5. Press 'New' button to define first condition
IfElse05.jpg
6. type in following text (during typing you can see some helping system):

this.ActiveTrain.Name=="M7"

and press "OK" button
IfElse06.jpg
7. Rename just created condition as 'M7' (there is mistacke on picture :-) )
IfElse07.jpg
8. In the same way create second condition and name it as 'not M7'

this.ActiveTrain.Name!="M7"

9. After creating all condition select condition 'M7' and press OK to assign it to Branch
IfElse08.jpg
IfElse09.jpg
10. Next select right 'ifElseBranchActivity2', select 'ConditionName', press '...' button, select 'not M7' condition and press 'OK button
IfElse10.jpg
11. Drag 'Train_ChangeSpeedDirFx' to left branch, select 'Speed change' as 'SetSteps' and 'Speed' as '110'
IfElse11.jpg
The end.

Awatar użytkownika
gbbsoft
Admin
Posty: 1533
Rejestracja: 09 lip 2008, 23:19
System DCC: Lenz + Roco

Re: changing events for a particular loco

Post autor: gbbsoft » 16 cze 2011, 16:56

There is a list of interesting properties of 'this' object:

For events in blocks:
ActiveTrain - this is current train in block
ActiveBlock - this is block itself

for events on trains:
ActiveTrain - this is train itself
ActiveBlock - this is current block

Train and Block has a lot of interesing properties (eg. Name)...

Awatar użytkownika
robs on the job
Posty: 19
Rejestracja: 16 paź 2009, 13:37

Re: changing events for a particular loco

Post autor: robs on the job » 16 cze 2011, 21:01

Many thanks for doing that
Rob the man who knows nothing about anything....I know!!! no I dont!

ODPOWIEDZ