diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm
index 6752128279..23771cadfb 100644
--- a/code/game/machinery/autolathe.dm
+++ b/code/game/machinery/autolathe.dm
@@ -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 += "
Printable Designs
"
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()
..()
diff --git a/code/game/machinery/autolathe_datums.dm b/code/game/machinery/autolathe_datums.dm
index b94f42d0c6..996daa2d10 100644
--- a/code/game/machinery/autolathe_datums.dm
+++ b/code/game/machinery/autolathe_datums.dm
@@ -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
diff --git a/code/world.dm b/code/world.dm
index 9515f33bb6..e8cfc45ba9 100644
--- a/code/world.dm
+++ b/code/world.dm
@@ -58,6 +58,9 @@ var/global/datum/global_init/init = new ()
// 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()