From 3f1b2b4d6ef80fe118f4da4f3b70b89f32fdafd3 Mon Sep 17 00:00:00 2001 From: FalseIncarnate Date: Mon, 23 Apr 2018 21:43:13 -0400 Subject: [PATCH] Refactors stack handling --- code/game/objects/items/mixing_bowl.dm | 26 +++++++++++------ .../kitchen_machinery/kitchen_machine.dm | 29 +++++++++++-------- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/code/game/objects/items/mixing_bowl.dm b/code/game/objects/items/mixing_bowl.dm index 8fa92b91368..ec9b6af8fa9 100644 --- a/code/game/objects/items/mixing_bowl.dm +++ b/code/game/objects/items/mixing_bowl.dm @@ -29,16 +29,16 @@ if(contents.len>=max_n_of_items) to_chat(user, "This [src] is full of ingredients, you cannot put more.") return 1 - if(istype(I, /obj/item/stack) && I:amount > 1) - new I.type (src) - I:use(1) - user.visible_message("[user] has added one of [I] to [src].", "You add one of [I] to [src].") + if(istype(I, /obj/item/stack)) + var/obj/item/stack/S = I + if(S.amount > 1) + new S.type (src) + S.use(1) + user.visible_message("[user] has added one of [S] to [src].", "You add one of [S] to [src].") + else + return add_item(S, user) else - if(!user.drop_item()) - to_chat(user, "\The [I] is stuck to your hand, you cannot put it in [src]") - return 0 - I.forceMove(src) - user.visible_message("[user] has added [I] to [src].", "You add [I] to [src].") + return add_item(I, user) else if(is_type_in_list(I, list(/obj/item/reagent_containers/glass, /obj/item/reagent_containers/food/drinks, /obj/item/reagent_containers/food/condiment))) if(!I.reagents) return 1 @@ -50,6 +50,14 @@ to_chat(user, "You have no idea what you can cook with [I].") return 1 +/obj/item/mixing_bowl/proc/add_item(obj/item/I, mob/user) + if(!user.drop_item()) + to_chat(user, "\The [I] is stuck to your hand, you cannot put it in [src]") + //return 0 + else + I.forceMove(src) + user.visible_message("[user] has added [I] to [src].", "You add [I] to [src].") + /obj/item/mixing_bowl/attack_self(mob/user) var/dat = "" if(dirty) diff --git a/code/modules/food_and_drinks/kitchen_machinery/kitchen_machine.dm b/code/modules/food_and_drinks/kitchen_machinery/kitchen_machine.dm index d13d80600de..41fc6613f31 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/kitchen_machine.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/kitchen_machine.dm @@ -127,19 +127,16 @@ if(contents.len>=max_n_of_items) to_chat(user, "This [src] is full of ingredients, you cannot put more.") return 1 - if(istype(O,/obj/item/stack) && O:amount>1) - new O.type (src) - O:use(1) - user.visible_message( \ - "[user] has added one of [O] to [src].", \ - "You add one of [O] to [src].") + if(istype(O,/obj/item/stack)) + var/obj/item/stack/S = O + if(S.amount > 1) + new S.type (src) + S.use(1) + user.visible_message("[user] has added one of [S] to [src].", "You add one of [S] to [src].") + else + add_item(S, user) else - if(!user.drop_item()) - to_chat(user, "\The [O] is stuck to your hand, you cannot put it in [src]") - return 0 - - O.forceMove(src) - user.visible_message("[user] has added [O] to [src].", "You add [O] to [src].") + add_item(O, user) else if(is_type_in_list(O, list(/obj/item/reagent_containers/glass, /obj/item/reagent_containers/food/drinks, /obj/item/reagent_containers/food/condiment))) if(!O.reagents) return 1 @@ -155,6 +152,14 @@ return 1 updateUsrDialog() +/obj/machinery/kitchen_machine/proc/add_item(obj/item/I, mob/user) + if(!user.drop_item()) + to_chat(user, "\The [I] is stuck to your hand, you cannot put it in [src]") + //return 0 + else + I.forceMove(src) + user.visible_message("[user] has added [I] to [src].", "You add [I] to [src].") + /obj/machinery/kitchen_machine/attack_ai(mob/user) return 0