mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 12:35:33 +01:00
Merge pull request #15554 from Menshin/autolathe_stacks_fix
Fix autolathe merging on top stacks without checking for types
This commit is contained in:
@@ -112,7 +112,7 @@
|
||||
return 1
|
||||
if(stat)
|
||||
return 1
|
||||
|
||||
|
||||
if(istype(O, /obj/item/weapon/disk/design_disk))
|
||||
user.visible_message("[user] begins to load \the [O] in \the [src]...",
|
||||
"You begin to load a design from \the [O]...",
|
||||
@@ -121,10 +121,10 @@
|
||||
var/obj/item/weapon/disk/design_disk/D = O
|
||||
if(do_after(user, 14.4, target = src))
|
||||
files.AddDesign2Known(D.blueprint)
|
||||
|
||||
|
||||
busy = 0
|
||||
return
|
||||
|
||||
|
||||
var/material_amount = materials.get_item_material_amount(O)
|
||||
if(!material_amount)
|
||||
user << "<span class='warning'>This object does not contain sufficient amounts of metal or glass to be accepted by the autolathe.</span>"
|
||||
@@ -177,8 +177,7 @@
|
||||
var/multiplier = text2num(href_list["multiplier"])
|
||||
var/max_multiplier = min(being_built.maxstack, being_built.materials[MAT_METAL] ?round(materials.amount(MAT_METAL)/being_built.materials[MAT_METAL]):INFINITY,being_built.materials[MAT_GLASS]?round(materials.amount(MAT_GLASS)/being_built.materials[MAT_GLASS]):INFINITY)
|
||||
var/is_stack = ispath(being_built.build_path, /obj/item/stack)
|
||||
|
||||
|
||||
|
||||
if(!is_stack && (multiplier > 1))
|
||||
return
|
||||
if (!(multiplier in list(1,10,25,max_multiplier))) //"enough materials ?" is checked further down
|
||||
@@ -202,27 +201,13 @@
|
||||
var/list/materials_used = list(MAT_METAL=metal_cost*multiplier, MAT_GLASS=glass_cost*multiplier)
|
||||
materials.use_amount(materials_used)
|
||||
|
||||
for(var/obj/item/stack/S in T)
|
||||
if(multiplier <= 0)
|
||||
break
|
||||
if(S.amount >= S.max_amount)
|
||||
continue
|
||||
var/to_transfer = S.max_amount - S.amount
|
||||
if(to_transfer < multiplier)
|
||||
S.amount += to_transfer
|
||||
multiplier -= to_transfer
|
||||
S.update_icon()
|
||||
continue
|
||||
else
|
||||
S.amount += multiplier
|
||||
multiplier = 0
|
||||
S.update_icon()
|
||||
break
|
||||
if(multiplier)
|
||||
var/obj/item/stack/N = new being_built.build_path(T)
|
||||
N.amount = multiplier
|
||||
N.update_icon()
|
||||
N.autolathe_crafted(src)
|
||||
var/obj/item/stack/N = new being_built.build_path(T, multiplier)
|
||||
N.update_icon()
|
||||
N.autolathe_crafted(src)
|
||||
|
||||
for(var/obj/item/stack/S in T.contents - N)
|
||||
if(istype(S, N.merge_type))
|
||||
N.merge(S)
|
||||
else
|
||||
var/list/materials_used = list(MAT_METAL=metal_cost/coeff, MAT_GLASS=glass_cost/coeff)
|
||||
materials.use_amount(materials_used)
|
||||
|
||||
Reference in New Issue
Block a user