Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] loopable looms #1535

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]")