mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Fixes #10314
Replaces every check for a hardcoded material stack type with a check for material of the stack.
This commit is contained in:
@@ -104,16 +104,13 @@ using metal and glass, it uses glass and reagents (usually sulfuric acis).
|
||||
return 1
|
||||
if(O.is_open_container())
|
||||
return 0
|
||||
// if(!istype(O, /obj/item/stack/material/glass) && !istype(O, /obj/item/stack/material/gold) && !istype(O, /obj/item/stack/material/diamond) && !istype(O, /obj/item/stack/material/uranium))
|
||||
// user << "<span class='notice'>You cannot insert this item into \the [src]!</span>"
|
||||
// return 1
|
||||
if(stat)
|
||||
return 1
|
||||
if(busy)
|
||||
user << "<span class='notice'>\The [src] is busy. Please wait for completion of previous operation.</span>"
|
||||
return 1
|
||||
|
||||
if(istype(O, /obj/item/stack/material/glass) || istype(O, /obj/item/stack/material/gold) || istype(O, /obj/item/stack/material/diamond) || istype(O, /obj/item/stack/material/uranium))
|
||||
if(istype(O, /obj/item/stack/material) && O.get_material_name() in list("glass", "gold", "diamond", "uranium"))
|
||||
|
||||
var/obj/item/stack/material/stack = O
|
||||
if((TotalMaterials() + stack.perunit) > max_material_amount)
|
||||
|
||||
@@ -144,28 +144,29 @@ Note: Must be placed west/left of and R&D console to function.
|
||||
icon_state = "protolathe"
|
||||
busy = 1
|
||||
use_power(max(1000, (3750 * amount / 10)))
|
||||
var/stacktype = stack.type
|
||||
stack.use(amount)
|
||||
if(do_after(user, 16))
|
||||
var/material/material = stack.get_material()
|
||||
if(istype(material) && stack.use(amount) && do_after(user, 16))
|
||||
user << "<span class='notice'>You add [amount] sheets to \the [src].</span>"
|
||||
icon_state = "protolathe"
|
||||
switch(stacktype)
|
||||
if(/obj/item/stack/material/steel)
|
||||
m_amount += amount * 3750
|
||||
if(/obj/item/stack/material/glass)
|
||||
g_amount += amount * 3750
|
||||
if(/obj/item/stack/material/gold)
|
||||
gold_amount += amount * 2000
|
||||
if(/obj/item/stack/material/silver)
|
||||
silver_amount += amount * 2000
|
||||
if(/obj/item/stack/material/phoron)
|
||||
phoron_amount += amount * 2000
|
||||
if(/obj/item/stack/material/uranium)
|
||||
uranium_amount += amount * 2000
|
||||
if(/obj/item/stack/material/diamond)
|
||||
diamond_amount += amount * 2000
|
||||
else
|
||||
new stacktype(loc, amount)
|
||||
|
||||
var/amount_to_add = amount * material.stack_per_sheet
|
||||
switch(material.name)
|
||||
if(DEFAULT_WALL_MATERIAL)
|
||||
m_amount += amount_to_add
|
||||
if("glass")
|
||||
g_amount += amount_to_add
|
||||
if("gold")
|
||||
gold_amount += amount_to_add
|
||||
if("silver")
|
||||
silver_amount += amount_to_add
|
||||
if("phoron")
|
||||
phoron_amount += amount_to_add
|
||||
if("uranium")
|
||||
uranium_amount += amount_to_add
|
||||
if("diamond")
|
||||
diamond_amount += amount_to_add
|
||||
else if(ispath(material.stack_type))
|
||||
new material.stack_type(loc, amount) //failed, so spit the material back out
|
||||
busy = 0
|
||||
updateUsrDialog()
|
||||
return
|
||||
|
||||
@@ -439,25 +439,24 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
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 = name_to_material[href_list["lathe_ejectsheet"]]
|
||||
var/material/M = get_material_by_name(href_list["lathe_ejectsheet"])
|
||||
if(istype(M))
|
||||
type = M.stack_type
|
||||
|
||||
switch(name_to_material[href_list["lathe_ejectsheet"]])
|
||||
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"
|
||||
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"
|
||||
|
||||
if(ispath(type) && hasvar(linked_lathe, res_amount))
|
||||
var/obj/item/stack/material/sheet = new type(linked_lathe.loc)
|
||||
|
||||
Reference in New Issue
Block a user