Generalizing lathe recipes.

This commit is contained in:
Zuhayr
2014-11-24 17:20:41 +10:30
parent 7b460feffe
commit 2b93a89d51
3 changed files with 29 additions and 21 deletions

View File

@@ -8,6 +8,7 @@
idle_power_usage = 10
active_power_usage = 100
var/list/machine_recipes
var/list/stored_material = list("metal" = 0, "glass" = 0)
var/list/storage_capacity = list("metal" = 0, "glass" = 0)
var/show_category = "All"
@@ -45,7 +46,7 @@
dat += "<h2>Printable Designs</h2><h3>Showing: <a href='?src=\ref[src];change_category=1'>[show_category]</a>.</h3></center><table width = '100%'>"
var/index = 0
for(var/datum/autolathe/recipe/R in autolathe_recipes)
for(var/datum/autolathe/recipe/R in machine_recipes)
index++
if(R.hidden && !hacked || (show_category != "All" && show_category != R.category))
continue
@@ -206,14 +207,14 @@
if(!choice) return
show_category = choice
if(href_list["make"] && autolathe_recipes)
if(href_list["make"] && machine_recipes)
var/index = text2num(href_list["make"])
var/multiplier = text2num(href_list["multiplier"])
var/datum/autolathe/recipe/making
if(index > 0 && index <= autolathe_recipes.len)
making = autolathe_recipes[index]
if(index > 0 && index <= machine_recipes.len)
making = machine_recipes[index]
//Exploit detection, not sure if necessary after rewrite.
if(!making || multiplier < 0 || multiplier > 100)
@@ -312,23 +313,6 @@
..()
//Create global autolathe recipe list if it hasn't been made already.
if(isnull(autolathe_recipes))
autolathe_recipes = list()
autolathe_categories = list()
for(var/R in typesof(/datum/autolathe/recipe)-/datum/autolathe/recipe)
var/datum/autolathe/recipe/recipe = new R
autolathe_recipes += recipe
autolathe_categories |= recipe.category
var/obj/item/I = new recipe.path
if(I.matter && !recipe.resources) //This can be overidden in the datums.
recipe.resources = list()
for(var/material in I.matter)
if(!isnull(storage_capacity[material]))
recipe.resources[material] = round(I.matter[material]*1.25) // More expensive to produce than they are to recycle.
del(I)
//Create parts for lathe.
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/autolathe(src)
@@ -362,6 +346,10 @@
disable_wire = pick(w)
w -= disable_wire
/obj/machinery/autolathe/initialize()
..()
machine_recipes = autolathe_recipes
//Updates overall lathe storage size.
/obj/machinery/autolathe/RefreshParts()
..()

View File

@@ -1,6 +1,23 @@
/var/global/list/autolathe_recipes
/var/global/list/autolathe_categories
/proc/populate_lathe_recipes()
//Create global autolathe recipe list if it hasn't been made already.
autolathe_recipes = list()
autolathe_categories = list()
for(var/R in typesof(/datum/autolathe/recipe)-/datum/autolathe/recipe)
var/datum/autolathe/recipe/recipe = new R
autolathe_recipes += recipe
autolathe_categories |= recipe.category
var/obj/item/I = new recipe.path
if(I.matter && !recipe.resources) //This can be overidden in the datums.
recipe.resources = list()
for(var/material in I.matter)
recipe.resources[material] = round(I.matter[material]*1.25) // More expensive to produce than they are to recycle.
del(I)
/datum/autolathe/recipe
var/name = "object"
var/path

View File

@@ -46,6 +46,9 @@
// due to this list not being instantiated.
populate_seed_list()
// Create autolathe recipes, as above.
populate_lathe_recipes()
master_controller = new /datum/controller/game_controller()
spawn(1)
master_controller.setup()