From 2f8aa744bca95a5cb8013cbe5c3384976a9514f9 Mon Sep 17 00:00:00 2001 From: Zuhayr Date: Mon, 16 Feb 2015 21:11:54 +1030 Subject: [PATCH] Well now the microwave works except for anything involving fruit. I hate this code. --- code/datums/recipe.dm | 30 +++++++++++------------- code/game/machinery/kitchen/microwave.dm | 2 +- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/code/datums/recipe.dm b/code/datums/recipe.dm index 4ee9649927..1729d7c5f4 100644 --- a/code/datums/recipe.dm +++ b/code/datums/recipe.dm @@ -26,10 +26,7 @@ * * Functions you do not need to call directly but could: * /datum/recipe/proc/check_reagents(var/datum/reagents/avail_reagents) - * //1=precisely, 0=insufficiently, -1=superfluous - * * /datum/recipe/proc/check_items(var/obj/container as obj) - * //1=precisely, 0=insufficiently, -1=superfluous * * */ @@ -46,11 +43,11 @@ var/aval_r_amnt = avail_reagents.get_reagent_amount(r_r) if (!(abs(aval_r_amnt - reagents[r_r])<0.5)) //if NOT equals if (aval_r_amnt>reagents[r_r]) - . = -1 + . = 0 else - return 0 + return -1 if ((reagents?(reagents.len):(0)) < avail_reagents.reagent_list.len) - return -1 + return 0 return . /datum/recipe/proc/check_fruit(var/obj/container) @@ -66,9 +63,9 @@ for(var/ktag in checklist) if(!isnull(checklist[ktag])) if(checklist[ktag] < 0) - . = -1 - else if(checklist[ktag] > 0) . = 0 + else if(checklist[ktag] > 0) + . = -1 break return . @@ -84,9 +81,9 @@ found = 1 break if (!found) - . = -1 + . = 0 if (checklist.len) - . = 0 + . = -1 return . //general version @@ -100,6 +97,10 @@ // food-related /datum/recipe/proc/make_food(var/obj/container as obj) + world << "trying to make [result]." + if(!result) + world << "Recipe is defined without a result, please bug this." + return var/obj/result_obj = new result(container) for (var/obj/O in (container.contents-result_obj)) if (O.reagents) @@ -111,14 +112,11 @@ return result_obj /proc/select_recipe(var/list/datum/recipe/avaiable_recipes, var/obj/obj as obj, var/exact) - if (!exact) - exact = -1 - else - exact = 1 var/list/datum/recipe/possible_recipes = new for (var/datum/recipe/recipe in avaiable_recipes) - if (recipe.check_reagents(obj.reagents)==exact && recipe.check_items(obj)==exact && recipe.check_fruit(obj)==exact) - possible_recipes+=recipe + var/target = exact ? 0 : 1 + if(recipe.check_reagents(obj.reagents) >= target && recipe.check_items(obj) >= target && recipe.check_fruit(obj) >= target) + possible_recipes |= recipe if (possible_recipes.len==0) return null else if (possible_recipes.len==1) diff --git a/code/game/machinery/kitchen/microwave.dm b/code/game/machinery/kitchen/microwave.dm index 45e32948b5..76fdf631d6 100644 --- a/code/game/machinery/kitchen/microwave.dm +++ b/code/game/machinery/kitchen/microwave.dm @@ -274,7 +274,7 @@ cooked.loc = src.loc return -/obj/machinery/microwave/proc/wzhzhzh(var/seconds as num) +/obj/machinery/microwave/proc/wzhzhzh(var/seconds as num) // Whoever named this proc is fucking literally Satan. ~ Z for (var/i=1 to seconds) if (stat & (NOPOWER|BROKEN)) return 0