Skip to content

Commit

Permalink
Better Eject_material_of_type
Browse files Browse the repository at this point in the history
  • Loading branch information
hex37 committed Jun 17, 2023
1 parent 4c4f37e commit ce21042
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions code/game/machinery/machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,13 @@ Class Procs:

/obj/machinery/proc/eject_material_of_type(var/incoming_material) //Used for autolathe, protolathe, mechfab, exofab. Stuff that takes materials, basically.
if(LAZYLEN(materials))
for(var/mat in materials)
if(mat != incoming_material)
continue
var/datum/material/M = get_material_by_name(mat)
if(!istype(M) || materials[mat] == 0)
continue
var/obj/item/stack/material/S = new M.stack_type(get_turf(src))
if(materials[mat] >= S.perunit)
S.amount = round(materials[mat] / S.perunit)
else
qdel(S) //Prevents stacks smaller than 1
if(materials[incoming_material])
var/datum/material/M = get_material_by_name(incoming_material)
if(!istype(M))
return

while(materials[incoming_material] > M.perunit)
var/obj/item/stack/material/S = new M.stack_type(get_turf(src))
S.amount = min(round(materials[incoming_material] / S.perunit), S.max_amount)
materials[incoming_material] -= (S.amount * S.perunit)
return

0 comments on commit ce21042

Please sign in to comment.