From 6470a08ae3b583f8530bab7686b29463f341e9c2 Mon Sep 17 00:00:00 2001 From: TheFurryFeline <38586851+TheFurryFeline@users.noreply.github.com> Date: Thu, 2 May 2019 22:08:48 -0400 Subject: [PATCH] Conveyor Fixes Make them able to go the right directions, even when you make new ones. --- code/modules/recycling/conveyor2.dm | 40 +++++++++++++++++++---------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm index d1be4f08da..3aaaa6e555 100644 --- a/code/modules/recycling/conveyor2.dm +++ b/code/modules/recycling/conveyor2.dm @@ -1,3 +1,8 @@ +//TFF 2/5/19: Port Polaris's conveyor movement fixes - set define value from 2 to -1 for reverse direction in movement. +#define OFF 0 +#define FORWARDS 1 +#define BACKWARDS -1 + //conveyor2 is pretty much like the original, except it supports corners, but not diverters. //note that corner pieces transfer stuff clockwise when running forward, and anti-clockwise backwards. @@ -10,7 +15,7 @@ layer = ABOVE_TURF_LAYER anchored = 1 circuit = /obj/item/weapon/circuitboard/conveyor - var/operating = 0 // 1 if running forward, -1 if backwards, 0 if off + var/operating = OFF // 1 if running forward, -1 if backwards, 0 if off var/operable = 1 // true if can operate (no broken segments in this belt run) var/forwards // this is the default (forward) direction, set by the map dir var/backwards // hopefully self-explanatory @@ -28,12 +33,7 @@ if(newdir) set_dir(newdir) - if(dir & (dir-1)) // Diagonal. Forwards is *away* from dir, curving to the right. - forwards = turn(dir, 135) - backwards = turn(dir, 45) - else - forwards = dir - backwards = turn(dir, 180) + update_dir() //TFF 2/5/19: Port Polaris's conveyor movement fixes if(on) operating = 1 @@ -48,22 +48,36 @@ RefreshParts() /obj/machinery/conveyor/proc/setmove() - if(operating == 1) + if(operating == FORWARDS) //TFF: Port Polaris updoot. movedir = forwards - else if(operating == -1) + else if(operating == BACKWARDS) //TFF: Port Polaris updoot. movedir = backwards - else operating = 0 + else + operating = OFF update() +//TFF 2/5/19: Port Polaris's conveyor movement fixes - handle proper movement directions when conveyor is on. +/obj/machinery/conveyor/set_dir() + .=..() + update_dir() + +/obj/machinery/conveyor/proc/update_dir() + if(!(dir in cardinal)) // Diagonal. Forwards is *away* from dir, curving to the right. + forwards = turn(dir, 135) + backwards = turn(dir, 45) + else + forwards = dir + backwards = turn(dir, 180) + /obj/machinery/conveyor/proc/update() if(stat & BROKEN) icon_state = "conveyor-broken" - operating = 0 + operating = OFF return if(!operable) - operating = 0 + operating = OFF if(stat & NOPOWER) - operating = 0 + operating = OFF icon_state = "conveyor[operating]" // machine process