Hi!

Here's some little description:

my._direction=1-2*(my.z>gc_elestop[my._destination]); // go up if not my.z>my._destination (over the dest.point)
ok - this part is havy to understand.
rule no.1 in programming fast code is to use methematic!

At the beginning our evelator (ele) has a arbitrary z-position.
Triggert by an event (in my case the 1-,2-,3-,4-,5-key) i tell the ele his destination(-index of the stop-position-array) and tell him also to move on (_moving=on).

In the action you can see that ele is waiting until _moving==on. (//wait for activating)
Now he calculates the direction he needs to move:
(read the line from behind to the beginning!)

1. gc_elestop[my._destination], this is one of the stop-positions declared at the top. An array always begins with index 0, so the first value is gc_elestop[0], the second gc_elestop[1], a.s.o...
(example: let say ele has the z-pos 0 and _desination is 3 -> gc_elestop[my._destination] = 600)

2. (my.z>gc_elestop[my._destination]), is a logical comparison like "if my.z>gc_elestop[my._destination]" and has 0 (off) or 1 (on) as result, what we can use for calculation!
(example: my.z>gc_elestop[my._destination] -> 0 > 600 = 0)

3. 1-2*(my.z>gc_elestop[my._destination]), (multiplication comes bevor substraction): I want have 1 if the ele should go up, and -1 to move down.
take the 1: this means go up
take the -2*(my.z>gc_elestop[my._destination]: this means substract 2 times the result of the comparison. (2 times to get not 0 as the total result but -1)
(example: 1-2*(0>600) = 1-2*(0) = 1)
(example it ele is upper the destination: 1-2*(800>600) = 1-2*(1) = -1)

So we have the direction.

What does _direction?

Look at line my.z+=time*gc_ele_speed*my._direction
It means: move ele (at the z-axis) in the _direction multiplied my time and speed_constant. (of cause there is NO collision-detection.)

Where to stop?
In the loop where the ele moves we constanly ask if the ele has passed the actual stop-position depending of his both possible directions.
If he has passed (after the loop), we set the exact position and stop the ele (_moving=off), so he will wait again until _moving=on is set (by a trigger).

hope I could help?

mercuryus