diff --git a/code/modules/materials/material_sheets.dm b/code/modules/materials/material_sheets.dm index a4379cf871c..9daa14d1faf 100644 --- a/code/modules/materials/material_sheets.dm +++ b/code/modules/materials/material_sheets.dm @@ -9,7 +9,7 @@ var/default_type = DEFAULT_WALL_MATERIAL var/material/material - var/perunit + var/perunit = SHEET_MATERIAL_AMOUNT var/apply_colour //temp pending icon rewrite /obj/item/stack/material/New() @@ -28,7 +28,6 @@ stacktype = material.stack_type if(islist(material.stack_origin_tech)) origin_tech = material.stack_origin_tech.Copy() - perunit = SHEET_MATERIAL_AMOUNT if(apply_colour) color = material.icon_colour diff --git a/code/modules/research/circuitprinter.dm b/code/modules/research/circuitprinter.dm index dd796d7147b..0e3858e662d 100644 --- a/code/modules/research/circuitprinter.dm +++ b/code/modules/research/circuitprinter.dm @@ -8,8 +8,6 @@ using metal and glass, it uses glass and reagents (usually sulphuric acid). name = "Circuit Imprinter" icon_state = "circuit_imprinter" flags = OPENCONTAINER - - var/list/materials = list("metal" = 0, "glass" = 0, "gold" = 0, "silver" = 0, "phoron" = 0, "uranium" = 0, "diamond" = 0) var/list/datum/design/queue = list() var/progress = 0 @@ -17,6 +15,8 @@ using metal and glass, it uses glass and reagents (usually sulphuric acid). var/mat_efficiency = 1 var/speed = 1 + materials = list("metal" = 0, "glass" = 0, "gold" = 0, "silver" = 0, "phoron" = 0, "uranium" = 0, "diamond" = 0) + use_power = 1 idle_power_usage = 30 active_power_usage = 2500 diff --git a/code/modules/research/protolathe.dm b/code/modules/research/protolathe.dm index c91a22d89f5..8809ee29554 100644 --- a/code/modules/research/protolathe.dm +++ b/code/modules/research/protolathe.dm @@ -8,7 +8,6 @@ active_power_usage = 5000 var/max_material_storage = 100000 - var/list/materials = list(DEFAULT_WALL_MATERIAL = 0, "glass" = 0, "gold" = 0, "silver" = 0, "phoron" = 0, "uranium" = 0, "diamond" = 0) var/list/datum/design/queue = list() var/progress = 0 @@ -16,6 +15,8 @@ var/mat_efficiency = 1 var/speed = 1 + materials = list(DEFAULT_WALL_MATERIAL = 0, "glass" = 0, "gold" = 0, "silver" = 0, "phoron" = 0, "uranium" = 0, "diamond" = 0) + /obj/machinery/r_n_d/protolathe/New() ..() component_parts = list() diff --git a/code/modules/research/rdconsole.dm b/code/modules/research/rdconsole.dm index 3a5ccd7440a..9f9315eba6c 100644 --- a/code/modules/research/rdconsole.dm +++ b/code/modules/research/rdconsole.dm @@ -360,59 +360,10 @@ won't update every console in existence) but it's more of a hassle to do. Also, linked_lathe.removeFromQueue(text2num(href_list["removeP"])) else if(href_list["lathe_ejectsheet"] && linked_lathe) //Causes the protolathe to eject a sheet of material - var/desired_num_sheets = text2num(href_list["amount"]) - var/res_amount, type - var/material/M = get_material_by_name(href_list["lathe_ejectsheet"]) - if(istype(M)) - type = M.stack_type - switch(M.name) - if(DEFAULT_WALL_MATERIAL) - res_amount = "m_amount" - if("glass") - res_amount = "g_amount" - if("gold") - res_amount = "gold_amount" - if("silver") - res_amount = "silver_amount" - if("phoron") - res_amount = "phoron_amount" - if("uranium") - res_amount = "uranium_amount" - if("diamond") - res_amount = "diamond_amount" + linked_lathe.eject(href_list["lathe_ejectsheet"], text2num(href_list["amount"])) - if(ispath(type) && hasvar(linked_lathe, res_amount)) - var/obj/item/stack/material/sheet = new type(linked_lathe.loc) - var/available_num_sheets = round(linked_lathe.vars[res_amount]/sheet.perunit) - if(available_num_sheets > 0) - sheet.amount = min(available_num_sheets, desired_num_sheets) - linked_lathe.vars[res_amount] = max(0, (linked_lathe.vars[res_amount] - sheet.amount * sheet.perunit)) - else - qdel(sheet) else if(href_list["imprinter_ejectsheet"] && linked_imprinter) //Causes the protolathe to eject a sheet of material - var/desired_num_sheets = text2num(href_list["amount"]) - var/res_amount, type - switch(href_list["imprinter_ejectsheet"]) - if("glass") - type = /obj/item/stack/material/glass - res_amount = "g_amount" - if("gold") - type = /obj/item/stack/material/gold - res_amount = "gold_amount" - if("diamond") - type = /obj/item/stack/material/diamond - res_amount = "diamond_amount" - if("uranium") - type = /obj/item/stack/material/uranium - res_amount = "uranium_amount" - if(ispath(type) && hasvar(linked_imprinter, res_amount)) - var/obj/item/stack/material/sheet = new type(linked_imprinter.loc) - var/available_num_sheets = round(linked_imprinter.vars[res_amount]/sheet.perunit) - if(available_num_sheets>0) - sheet.amount = min(available_num_sheets, desired_num_sheets) - linked_imprinter.vars[res_amount] = max(0, (linked_imprinter.vars[res_amount] - sheet.amount * sheet.perunit)) - else - qdel(sheet) + linked_imprinter.eject(href_list["imprinter_ejectsheet"], text2num(href_list["amount"])) else if(href_list["find_device"]) //The R&D console looks for devices nearby to link up with. screen = 0.0 diff --git a/code/modules/research/rdmachines.dm b/code/modules/research/rdmachines.dm index 031c82a9584..2bcf7ef66e3 100644 --- a/code/modules/research/rdmachines.dm +++ b/code/modules/research/rdmachines.dm @@ -11,6 +11,8 @@ var/busy = 0 var/obj/machinery/computer/rdconsole/linked_console + var/list/materials = list() + /obj/machinery/r_n_d/attack_hand(mob/user as mob) return @@ -47,4 +49,17 @@ if(/obj/item/stack/material/uranium) return "uranium" if(/obj/item/stack/material/diamond) - return "diamond" \ No newline at end of file + return "diamond" + +/obj/machinery/r_n_d/proc/eject(var/material, var/amount) + if(!(material in materials)) + return + var/obj/item/stack/material/sheetType = getMaterialType(material) + var/perUnit = initial(sheetType.perunit) + var/eject = round(materials[material] / perUnit) + eject = amount == -1 ? eject : min(eject, amount) + if(eject < 1) + return + var/obj/item/stack/material/S = new sheetType(loc) + S.amount = eject + materials[material] -= eject * perUnit \ No newline at end of file