Protolathe and CI will now correctly eject materials.
This commit is contained in:
Kelenius
2016-01-18 15:06:33 +03:00
parent 3d562f0085
commit ee531578d7
4 changed files with 29 additions and 53 deletions

View File

@@ -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

View File

@@ -201,3 +201,16 @@ using metal and glass, it uses glass and reagents (usually sulphuric acid).
if(new_item.matter && new_item.matter.len > 0)
for(var/i in new_item.matter)
new_item.matter[i] = new_item.matter[i] * mat_efficiency
/obj/machinery/r_n_d/circuit_imprinter/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

View File

@@ -202,3 +202,16 @@
if(new_item.matter && new_item.matter.len > 0)
for(var/i in new_item.matter)
new_item.matter[i] = new_item.matter[i] * mat_efficiency
/obj/machinery/r_n_d/protolathe/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

View File

@@ -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