From 7734d4d2be2c9580c2f76b14831c89a87da45c5f Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 14 Jan 2021 15:03:44 +0100 Subject: [PATCH] [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> --- code/modules/assembly/doorcontrol.dm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/modules/assembly/doorcontrol.dm b/code/modules/assembly/doorcontrol.dm index e1e813c5ff6..35cc75c4f21 100644 --- a/code/modules/assembly/doorcontrol.dm +++ b/code/modules/assembly/doorcontrol.dm @@ -190,8 +190,13 @@ return lift.visible_message("[src] clinks and whirrs into automated motion, locking controls. 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)