diff --git a/code/modules/research/machinery/_production.dm b/code/modules/research/machinery/_production.dm index 04c777bb1c0..d110dab03e0 100644 --- a/code/modules/research/machinery/_production.dm +++ b/code/modules/research/machinery/_production.dm @@ -411,14 +411,25 @@ var/atom/movable/created if(is_stack) - created = new design.build_path(target, items_remaining) + var/obj/item/stack/stack_item = initial(design.build_path) + var/max_stack_amount = initial(stack_item.max_amount) + var/number_to_make = (initial(stack_item.amount) * items_remaining) + while(number_to_make > max_stack_amount) + created = new stack_item(null, max_stack_amount) //it's imporant to spawn things in nullspace, since obj's like stacks qdel when they enter a tile/merge with other stacks of the same type, resulting in runtimes. + created.pixel_x = created.base_pixel_x + rand(-6, 6) + created.pixel_y = created.base_pixel_y + rand(-6, 6) + created.forceMove(target) + number_to_make -= max_stack_amount + + created = new stack_item(null, number_to_make) else - created = new design.build_path(target) + created = new design.build_path(null) split_materials_uniformly(design_materials, material_cost_coefficient, created) created.pixel_x = created.base_pixel_x + rand(-6, 6) created.pixel_y = created.base_pixel_y + rand(-6, 6) SSblackbox.record_feedback("nested tally", "lathe_printed_items", 1, list("[type]", "[created.type]")) + created.forceMove(target) if(is_stack) items_remaining = 0