From da469031c97ab3ede825faa0ab56ef3cd40c4ed5 Mon Sep 17 00:00:00 2001 From: Citinited Date: Sun, 4 Nov 2018 18:19:51 +0000 Subject: [PATCH 1/3] Conveyors switch between speedy and normal process now --- code/modules/recycling/conveyor2.dm | 32 ++++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm index 4bbc25a8037..82c638fd43b 100644 --- a/code/modules/recycling/conveyor2.dm +++ b/code/modules/recycling/conveyor2.dm @@ -1,6 +1,7 @@ #define DIRECTION_FORWARDS 1 #define DIRECTION_OFF 0 #define DIRECTION_REVERSED -1 +#define IS_OPERATING (can_conveyor_run() && operating) GLOBAL_LIST_INIT(conveyor_belts, list()) //Saves us having to look through the entire machines list for our things GLOBAL_LIST_INIT(conveyor_switches, list()) @@ -22,7 +23,6 @@ GLOBAL_LIST_INIT(conveyor_switches, list()) var/operable = TRUE // Can this belt actually go? var/list/affecting // the list of all items that will be moved this ptick var/reversed = FALSE // set to TRUE to have the conveyor belt be reversed - speed_process = TRUE //gotta go fast var/id //ID of the connected lever // create a conveyor @@ -84,7 +84,7 @@ GLOBAL_LIST_INIT(conveyor_switches, list()) /obj/machinery/conveyor/update_icon() ..() - if(operating && can_conveyor_run()) + if(IS_OPERATING) icon_state = "conveyor_started_[clockwise ? "cw" : "ccw"]" if(reversed) icon_state += "_r" @@ -161,20 +161,27 @@ GLOBAL_LIST_INIT(conveyor_switches, list()) update_icon() /obj/machinery/conveyor/process() - if(!operating) - return - if(!can_conveyor_run()) + if(!IS_OPERATING) return use_power(100) affecting = loc.contents - src // moved items will be all in loc - if(!affecting) - return - sleep(1) - for(var/atom/movable/A in affecting) - if(!A.anchored) - if(A.loc == loc) // prevents the object from being affected if it's not currently here. - step(A,forwards) + var/still_stuff_to_move = FALSE + for(var/atom/movable/AM in affecting) + if(AM.anchored) + continue + still_stuff_to_move = TRUE + sleep(1) + if(AM.loc == loc) // prevents the object from being affected if it's not currently here. + step(A,forwards) CHECK_TICK + if(!still_stuff_to_move) + makeNormalProcess() + else + makeSpeedProcess() + +/obj/machinery/conveyor/Crossed(atom/movable/AM) + makeSpeedProcess() + ..() /obj/machinery/conveyor/proc/can_conveyor_run() if(stat & BROKEN) @@ -475,3 +482,4 @@ GLOBAL_LIST_INIT(conveyor_switches, list()) #undef DIRECTION_FORWARDS #undef DIRECTION_OFF #undef DIRECTION_REVERSED +#undef IS_OPERATING From 5fb3fb71a19457aed912fb7ebcdf125c11c30375 Mon Sep 17 00:00:00 2001 From: Citinited Date: Sun, 4 Nov 2018 18:31:48 +0000 Subject: [PATCH 2/3] oops --- code/modules/recycling/conveyor2.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm index 82c638fd43b..95234c850d5 100644 --- a/code/modules/recycling/conveyor2.dm +++ b/code/modules/recycling/conveyor2.dm @@ -172,7 +172,7 @@ GLOBAL_LIST_INIT(conveyor_switches, list()) still_stuff_to_move = TRUE sleep(1) if(AM.loc == loc) // prevents the object from being affected if it's not currently here. - step(A,forwards) + step(AM,forwards) CHECK_TICK if(!still_stuff_to_move) makeNormalProcess() From 13b776b51cf561827cc9f535523225b3f7a50bd0 Mon Sep 17 00:00:00 2001 From: Citinited Date: Wed, 7 Nov 2018 18:20:05 +0000 Subject: [PATCH 3/3] Adds timer to conveyors; checks speed_process before trying to change to / from speed process --- code/modules/recycling/conveyor2.dm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm index 95234c850d5..e5ca5fb0d28 100644 --- a/code/modules/recycling/conveyor2.dm +++ b/code/modules/recycling/conveyor2.dm @@ -170,19 +170,22 @@ GLOBAL_LIST_INIT(conveyor_switches, list()) if(AM.anchored) continue still_stuff_to_move = TRUE - sleep(1) - if(AM.loc == loc) // prevents the object from being affected if it's not currently here. - step(AM,forwards) + addtimer(CALLBACK(src, .proc/move_thing, AM), 1) CHECK_TICK - if(!still_stuff_to_move) + if(!still_stuff_to_move && speed_process) makeNormalProcess() - else + else if(still_stuff_to_move && !speed_process) makeSpeedProcess() /obj/machinery/conveyor/Crossed(atom/movable/AM) - makeSpeedProcess() + if(!speed_process) + makeSpeedProcess() ..() +/obj/machinery/conveyor/proc/move_thing(atom/movable/AM) + if(!AM.anchored && AM.loc == loc) + step(AM, forwards) + /obj/machinery/conveyor/proc/can_conveyor_run() if(stat & BROKEN) return FALSE