This commit is contained in:
Rob Nelson
2013-11-17 17:30:28 -08:00
parent ff7bfe6d7c
commit 79ceaa4534
2 changed files with 12 additions and 4 deletions

View File

@@ -215,6 +215,7 @@ span.smelting {
for (i = 0; i < 10; i++)
var/located=0
var/insufficient_ore=0
// For every recipe
for(var/datum/smelting_recipe/recipe in recipes)
// Check if it's selected and we have the ingredients
@@ -228,6 +229,7 @@ span.smelting {
// Otherwise, if we've matched
else if(signal==1)
// Take ingredients
for(var/ore_id in recipe.ingredients)
ore[ore_id]--
@@ -248,7 +250,7 @@ span.smelting {
// Take one of every ore selected
for(var/ore_id in selected)
if(ore[ore_id]>0)
if(ore[ore_id]>0 && selected[ore_id])
ore[ore_id]--
// Spawn slag
new /obj/item/weapon/ore/slag(output.loc)

View File

@@ -6,8 +6,10 @@
// Note: Returns -1 if not enough ore!
/datum/smelting_recipe/proc/checkIngredients(var/obj/machinery/mineral/processing_unit/P)
var/sufficient_ore=1
var/matching_ingredient_count=0
for(var/ore_id in P.selected)
var/required=(ore_id in ingredients)
// Selected but not in ingredients
if(P.selected[ore_id] && !required)
return 0
@@ -19,13 +21,17 @@
var/min_ore_required=ingredients[ore_id]
// Selected, in ingredients, but not enough in stock.
if(P.selected[ore_id] && required && P.ore[ore_id] < min_ore_required)
sufficient_ore=0
if(P.selected[ore_id] && required)
if(P.ore[ore_id] < min_ore_required)
sufficient_ore=0
continue
matching_ingredient_count++
if(!sufficient_ore)
return -1 // -1 means not enough ore. NOT A TYPO.
return 1
return matching_ingredient_count == ingredients.len
// RECIPES BEEP BOOP
/datum/smelting_recipe/glass