From 79af914dc1019dcf985c821c2b6ab0f34c864043 Mon Sep 17 00:00:00 2001 From: SteelSlayer Date: Thu, 7 Nov 2019 17:53:38 -0600 Subject: [PATCH 1/4] Chemistry bag QoL improvement --- code/modules/reagents/chemistry/machinery/reagentgrinder.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm index 41a0a747118..c28eaf39fa1 100644 --- a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm +++ b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm @@ -176,7 +176,7 @@ //Fill machine with a bag! if(istype(I, /obj/item/storage/bag)) var/obj/item/storage/bag/B = I - for (var/obj/item/reagent_containers/food/snacks/grown/G in B.contents) + for (var/obj/item/reagent_containers/food/G in B.contents) B.remove_from_storage(G, src) holdingitems += G if(holdingitems && holdingitems.len >= limit) //Sanity checking so the blender doesn't overfill From 7b15c9e301661e61150a49ec93ea4f3c80de872f Mon Sep 17 00:00:00 2001 From: SteelSlayer Date: Thu, 7 Nov 2019 19:19:47 -0600 Subject: [PATCH 2/4] Forgot to include this --- code/modules/reagents/chemistry/machinery/reagentgrinder.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm index c28eaf39fa1..9203f095d85 100644 --- a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm +++ b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm @@ -184,7 +184,7 @@ break if(!I.contents.len) - to_chat(user, "You empty the plant bag into the All-In-One grinder.") + to_chat(user, "You empty [I] into the All-In-One grinder.") src.updateUsrDialog() return 1 From 7a04e5ee9b41e4ce0a23271eef6202f9e113fce0 Mon Sep 17 00:00:00 2001 From: SteelSlayer Date: Fri, 8 Nov 2019 10:42:59 -0600 Subject: [PATCH 3/4] indention and logic cleanup --- .../chemistry/machinery/reagentgrinder.dm | 130 ++++++++++-------- 1 file changed, 71 insertions(+), 59 deletions(-) diff --git a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm index 9203f095d85..e1371466dc2 100644 --- a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm +++ b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm @@ -134,76 +134,88 @@ icon_state = "juicer0" /obj/machinery/reagentgrinder/attackby(obj/item/I, mob/user, params) - if(default_unfasten_wrench(user, I)) - return + if(default_unfasten_wrench(user, I)) + return - if(exchange_parts(user, I)) - return + if(exchange_parts(user, I)) + return - if(anchored && !beaker) - if(default_deconstruction_screwdriver(user, "juicer_open", "juicer0", I)) - return + if(anchored && !beaker) + if(default_deconstruction_screwdriver(user, "juicer_open", "juicer0", I)) + return - if(panel_open && istype(I, /obj/item/crowbar)) - default_deconstruction_crowbar(I) - return + if(panel_open && istype(I, /obj/item/crowbar)) + default_deconstruction_crowbar(I) + return - if (istype(I, /obj/item/reagent_containers) && (I.container_type & OPENCONTAINER) ) - if(beaker) - to_chat(user, "There's already a container inside.") - else if(panel_open) - to_chat(user, "Close the maintenance panel first.") - else - if(!user.drop_item()) - return 1 - beaker = I - beaker.loc = src - update_icon() - src.updateUsrDialog() - return 1 //no afterattack + if(istype(I, /obj/item/reagent_containers) && (I.container_type & OPENCONTAINER) ) + if(beaker) + to_chat(user, "There's already a container inside.") + else if(panel_open) + to_chat(user, "Close the maintenance panel first.") + else + if(!user.drop_item()) + return TRUE + beaker = I + beaker.loc = src + update_icon() + updateUsrDialog() + return TRUE //no afterattack - if(is_type_in_list(I, dried_items)) - if(istype(I, /obj/item/reagent_containers/food/snacks/grown)) - var/obj/item/reagent_containers/food/snacks/grown/G = I - if(!G.dry) - to_chat(user, "You must dry that first!") - return 1 + if(is_type_in_list(I, dried_items)) + if(istype(I, /obj/item/reagent_containers/food/snacks/grown)) + var/obj/item/reagent_containers/food/snacks/grown/G = I + if(!G.dry) + to_chat(user, "You must dry that first!") + return TRUE - if(holdingitems && holdingitems.len >= limit) - to_chat(usr, "The machine cannot hold anymore items.") - return 1 + if(holdingitems && holdingitems.len >= limit) + to_chat(usr, "The machine cannot hold anymore items.") + return TRUE - //Fill machine with a bag! - if(istype(I, /obj/item/storage/bag)) - var/obj/item/storage/bag/B = I - for (var/obj/item/reagent_containers/food/G in B.contents) - B.remove_from_storage(G, src) - holdingitems += G - if(holdingitems && holdingitems.len >= limit) //Sanity checking so the blender doesn't overfill - to_chat(user, "You fill the All-In-One grinder to the brim.") - break + //Fill machine with a bag! + if(istype(I, /obj/item/storage/bag)) + var/obj/item/storage/bag/B = I + if(!B.contents.len) + to_chat(user, "[B] is empty.") + return FALSE - if(!I.contents.len) - to_chat(user, "You empty [I] into the All-In-One grinder.") + var/original_contents_len = B.contents.len - src.updateUsrDialog() - return 1 + for(var/obj/item/G in B.contents) + if(is_type_in_list(G, blend_items) || is_type_in_list(G, juice_items)) + B.remove_from_storage(G, src) + holdingitems += G + if(holdingitems && holdingitems.len >= limit) //Sanity checking so the blender doesn't overfill + to_chat(user, "You fill the All-In-One grinder to the brim.") + break - if (!is_type_in_list(I, blend_items) && !is_type_in_list(I, juice_items)) - if(user.a_intent == INTENT_HARM) - return ..() - else - to_chat(user, "Cannot refine into a reagent!") - return 1 + if(B.contents.len == original_contents_len) + to_chat(user, "Nothing in [B] can be put into the All-In-One grinder.") + return FALSE + else if(!B.contents.len) + to_chat(user, "You empty all of [B]'s contents into the All-In-One grinder.") + else + to_chat(user, "You empty some of [B]'s contents into the All-In-One grinder.") - if(user.drop_item()) - I.loc = src - holdingitems += I - src.updateUsrDialog() - return 0 + updateUsrDialog() + return TRUE + + if(!is_type_in_list(I, blend_items) && !is_type_in_list(I, juice_items)) + if(user.a_intent == INTENT_HARM) + return ..() + else + to_chat(user, "Cannot refine into a reagent!") + return TRUE + + if(user.drop_item()) + I.loc = src + holdingitems += I + src.updateUsrDialog() + return FALSE /obj/machinery/reagentgrinder/attack_ai(mob/user) - return 0 + return FALSE /obj/machinery/reagentgrinder/attack_hand(mob/user) user.set_machine(src) @@ -301,8 +313,8 @@ /obj/machinery/reagentgrinder/proc/is_allowed(obj/item/reagent_containers/O) for (var/i in blend_items) if(istype(O, i)) - return 1 - return 0 + return TRUE + return FALSE /obj/machinery/reagentgrinder/proc/get_allowed_by_id(obj/item/O) for (var/i in blend_items) From 21960b87228811252dde85f2a039e3dd05a23699 Mon Sep 17 00:00:00 2001 From: SteelSlayer Date: Mon, 11 Nov 2019 16:36:27 -0600 Subject: [PATCH 4/4] fixes some backwards return logic --- code/modules/reagents/chemistry/machinery/reagentgrinder.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm index e1371466dc2..9601746443a 100644 --- a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm +++ b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm @@ -155,7 +155,7 @@ to_chat(user, "Close the maintenance panel first.") else if(!user.drop_item()) - return TRUE + return FALSE beaker = I beaker.loc = src update_icon() @@ -167,11 +167,11 @@ var/obj/item/reagent_containers/food/snacks/grown/G = I if(!G.dry) to_chat(user, "You must dry that first!") - return TRUE + return FALSE if(holdingitems && holdingitems.len >= limit) to_chat(usr, "The machine cannot hold anymore items.") - return TRUE + return FALSE //Fill machine with a bag! if(istype(I, /obj/item/storage/bag))