mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 22:19:30 +01:00
[MIRROR] Autolathe takes as many sheets as it can fit [MDB IGNORE] (#10419)
* Autolathe takes as many sheets as it can fit (#63274) * Autolathe takes as many sheets as it can fit * what is invoke_async anyway is this how you do it * no i guess you do it like this still use a dot though * Autolathe takes as many sheets as it can fit Co-authored-by: cacogen <25089914+cacogen@users.noreply.github.com> Co-authored-by: GoldenAlpharex <jerego1234@hotmail.com>
This commit is contained in:
co-authored by
cacogen
GoldenAlpharex
parent
51ca5654a1
commit
c2aff0c31a
@@ -129,8 +129,21 @@
|
||||
to_chat(user, span_warning("[I] does not contain sufficient materials to be accepted by [parent]."))
|
||||
return
|
||||
if(!has_space(material_amount))
|
||||
to_chat(user, span_warning("[parent] is full. Please remove materials from [parent] in order to insert more."))
|
||||
return
|
||||
if(istype(I, /obj/item/stack))
|
||||
//figure out how much space is left
|
||||
var/space_left = max_amount - total_amount
|
||||
//figure out the amount of sheets that can fit that space
|
||||
var/obj/item/stack/stack_to_split = I
|
||||
var/material_per_sheet = material_amount / stack_to_split.amount
|
||||
var/sheets_to_insert = round(space_left / material_per_sheet)
|
||||
if(!sheets_to_insert)
|
||||
to_chat(user, span_warning("[parent] can't hold any more of [I] sheets."))
|
||||
return
|
||||
//split the amount we don't need off
|
||||
INVOKE_ASYNC(stack_to_split, /obj/item/stack.proc/split_stack, user, stack_to_split.amount - sheets_to_insert)
|
||||
else
|
||||
to_chat(user, span_warning("[I] contains more materials than [parent] has space to hold."))
|
||||
return
|
||||
user_insert(I, user, mat_container_flags)
|
||||
|
||||
/// Proc used for when player inserts materials
|
||||
|
||||
Reference in New Issue
Block a user