Skip to content

Commit

Permalink
Merge pull request #8858 from Twitchcog/Twitchcog/fix/what-does-a-nam…
Browse files Browse the repository at this point in the history
…e-matter

Autolathes accept mat stacks raw
  • Loading branch information
Spookerton committed Dec 13, 2022
2 parents 6ae04e1 + bcb267e commit d956a62
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions code/game/machinery/autolathe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -191,51 +191,47 @@
var/filltype = 0 // Used to determine message.
var/total_used = 0 // Amount of material used.
var/mass_per_sheet = 0 // Amount of material constituting one sheet.
var/list/matter_inputs
if(istype(eating, /obj/item/stack/material))
var/obj/item/stack/material/matstack = eating
matter_inputs = list(matstack.material.name = 2000)
else
matter_inputs = eating.matter

for(var/material in eating.matter)

for(var/material in matter_inputs)
if(isnull(stored_material[material]) || isnull(storage_capacity[material]))
continue

if(stored_material[material] >= storage_capacity[material])
continue

var/total_material = eating.matter[material]

var/total_material = matter_inputs[material]
//If it's a stack, we eat multiple sheets.
if(istype(eating,/obj/item/stack))
var/obj/item/stack/stack = eating
total_material *= stack.get_amount()

if(stored_material[material] + total_material > storage_capacity[material])
total_material = storage_capacity[material] - stored_material[material]
filltype = 1
else
filltype = 2

stored_material[material] += total_material
total_used += total_material
mass_per_sheet += eating.matter[material]

mass_per_sheet += matter_inputs[material]
if(!filltype)
to_chat(user, "<span class='notice'>\The [src] is full. Please remove material from the autolathe in order to insert more.</span>")
return
else if(filltype == 1)
to_chat(user, "You fill \the [src] to capacity with \the [eating].")
else
to_chat(user, "You fill \the [src] with \the [eating].")

flick("autolathe_loading", src) // Plays metal insertion animation. Work out a good way to work out a fitting animation. ~Z

if(istype(eating,/obj/item/stack))
var/obj/item/stack/stack = eating
stack.use(max(1, round(total_used/mass_per_sheet))) // Always use at least 1 to prevent infinite materials.
else
user.remove_from_mob(O)
qdel(O)

updateUsrDialog()
return


/obj/machinery/autolathe/attack_hand(mob/user as mob)
user.set_machine(src)
Expand Down

0 comments on commit d956a62

Please sign in to comment.