From 832a53e10df598ea06c5ed9c358708a19ecda4ec Mon Sep 17 00:00:00 2001 From: dovydas12345 Date: Fri, 9 Nov 2018 19:54:41 +0200 Subject: [PATCH] Slicing grown snacks --- code/modules/hydroponics/grown.dm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/code/modules/hydroponics/grown.dm b/code/modules/hydroponics/grown.dm index 2e0feaecea7..d4688fd81e8 100644 --- a/code/modules/hydroponics/grown.dm +++ b/code/modules/hydroponics/grown.dm @@ -60,6 +60,31 @@ /obj/item/reagent_containers/food/snacks/grown/attackby(obj/item/O, mob/user, params) ..() + if(slices_num && slices_num >0 && slice_path) + var/inaccurate = TRUE + if(O.sharp) + if(istype(O, /obj/item/kitchen/knife) || istype(O, /obj/item/scalpel)) + inaccurate = FALSE + + if(!isturf(loc) || !(locate(/obj/structure/table) in loc) && !(locate(/obj/machinery/optable) in loc) && !(locate(/obj/item/storage/bag/tray) in loc)) + to_chat(user, "You cannot slice [src] here! You need a table or at least a tray to do it.") + return TRUE + + var/slices_lost = 0 + if(!inaccurate) + user.visible_message("[user] slices [src]!", + "You slice [src]!") + else + user.visible_message("[user] crudely slices [src] with [O]!", "You crudely slice [src] with your [O]!") + slices_lost = rand(1,min(1,round(slices_num/2))) + + var/reagents_per_slice = reagents.total_volume/slices_num + for(var/i=1 to (slices_num-slices_lost)) + var/obj/slice = new slice_path (loc) + reagents.trans_to(slice,reagents_per_slice) + qdel(src) + return ..() + if (istype(O, /obj/item/plant_analyzer)) var/msg = "*---------*\n This is \a [src].\n" if(seed)