[MIRROR] Fix elevators movement when called via button (#2691)

* Fix elevators (#56117)

Currently elevators are broken since they try to use the z level of the assembly inside the button to determine how to move
The assemblies z level is however always 0 and instead the z level of the button containing the assembly must be used
This fixes this

* Fix elevators movement when called via button

Co-authored-by: Gamer025 <33846895+Gamer025@users.noreply.github.com>
This commit is contained in:
SkyratBot
2021-01-14 15:03:44 +01:00
committed by GitHub
co-authored by Gamer025
parent 66a822067c
commit 7734d4d2be
+7 -2
View File
@@ -190,8 +190,13 @@
return
lift.visible_message("<span class='notice'>[src] clinks and whirrs into automated motion, locking controls.</span")
lift.lift_master_datum.set_controls(LOCKED)
var/difference = abs(z - lift.z)
var/direction = lift.z > z ? UP : DOWN
///The z level to which the elevator should travel
var/targetZ = (abs(loc.z)) //The target Z (where the elevator should move to) is not our z level (we are just some assembly in nullspace) but actually the Z level of whatever we are contained in (e.g. elevator button)
///The amount of z levels between the our and targetZ
var/difference = abs(targetZ - lift.z)
///Direction (up/down) needed to go to reach targetZ
var/direction = lift.z < targetZ ? UP : DOWN
///How long it will/should take us to reach the target Z level
var/travel_duration = FLOOR_TRAVEL_TIME * difference //100 / 2 floors up = 50 seconds on every floor, will always reach destination in the same time
addtimer(VARSET_CALLBACK(src, cooldown, FALSE), travel_duration)
for(var/i in 1 to difference)