diff --git a/code/datums/elements/loomable.dm b/code/datums/elements/loomable.dm index cfd0b4bc834..76ee071a9a2 100644 --- a/code/datums/elements/loomable.dm +++ b/code/datums/elements/loomable.dm @@ -71,23 +71,33 @@ /// If a do_after of the specified loom_time passes, will create a new one of resulting_atom and either delete the item, or .use the required amount if its a stack /datum/element/loomable/proc/loom_me(obj/item/source, mob/living/user, atom/target) - if(!do_after(user, loom_time, target)) - user.balloon_alert(user, "interrupted!") - return - - ///we need to perform another check in case a stack somehow got diminished in the middle of the do_after - var/successful = TRUE + //this allows us to count the amount of times it has successfully used the stack's required amount + var/spawning_amount = 0 if(isstack(source)) var/obj/item/stack/stack_we_use = source - if(!stack_we_use.use(required_amount)) - successful = FALSE + while(stack_we_use.amount >= required_amount) + if(!do_after(user, loom_time, target)) + break + + if(!stack_we_use.use(required_amount)) + user.balloon_alert(user, "need [required_amount] of [source]!") + break + + spawning_amount++ + else + if(!do_after(user, loom_time, target)) + user.balloon_alert(user, "interrupted!") + return + qdel(source) + spawning_amount++ - //ripbozo - if(!successful) - user.balloon_alert(user, "need [required_amount] of [source]!") + if(spawning_amount == 0) return - var/new_thing = new resulting_atom(target.drop_location()) + var/new_thing + for(var/repeated in 1 to spawning_amount) + new_thing = new resulting_atom(target.drop_location()) + user.balloon_alert_to_viewers("[process_completion_verb] [new_thing]")