Skip to content

Commit

Permalink
[MIRROR] loopable looms [MDB IGNORE] (#25013)
Browse files Browse the repository at this point in the history
* loopable looms (#79680)

## About The Pull Request
makes the looms `loom_me` proc loop for stackable items (such as
cotton).
## Why It's Good For The Game
its a looping do_after, which is satisfying (and you don't need to click
as much).
## Changelog
:cl:
qol: looms will now attempt to loop through stackable items (cotton as
an example)
/:cl:

---------

Co-authored-by: san7890 <the@ san7890.com>

* loopable looms

---------

Co-authored-by: jjpark-kb <55967837+jjpark-kb@users.noreply.github.com>
Co-authored-by: san7890 <the@ san7890.com>
  • Loading branch information
3 people authored and FFMirrorBot committed Nov 14, 2023
1 parent 3517791 commit eb1b922
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions code/datums/elements/loomable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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]")

0 comments on commit eb1b922

Please sign in to comment.