Skip to content

Commit

Permalink
Auto Lathe Runtime Fixes (tgstation#83587)
Browse files Browse the repository at this point in the history
## About The Pull Request
- Fixes tgstation#83581

Using an autolathe in any area without an APC causes this runtime
![Screenshot
(417)](https://github.com/tgstation/tgstation/assets/110812394/bb10adbc-3702-4255-b93b-ca722cb8d67c)

Also caught another bug which causes the UI to hang if the lathe runs
out of material mid printing

## Changelog

:cl:
fix: autolathes don't hang when printing items in areas without apc or
if it runs out of materials mid printing
/:cl:

---------

Co-authored-by: san7890 <[email protected]>
  • Loading branch information
SyncIt21 and san7890 authored Jun 6, 2024
1 parent 9087058 commit 7a9e37b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions code/game/machinery/autolathe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,21 @@
if(!directly_use_energy(charge_per_item)) // provide the wait time until lathe is ready
var/area/my_area = get_area(src)
var/obj/machinery/power/apc/my_apc = my_area.apc
var/charging_wait = my_apc.time_to_charge(charge_per_item)
if(!isnull(charging_wait))
say("Unable to continue production, APC overload. Wait [DisplayTimeText(charging_wait, round_seconds_to = 1)] and try again.")
if(!QDELETED(my_apc))
var/charging_wait = my_apc.time_to_charge(charge_per_item)
if(!isnull(charging_wait))
say("Unable to continue production, APC overload. Wait [DisplayTimeText(charging_wait, round_seconds_to = 1)] and try again.")
else
say("Unable to continue production, power grid overload.")
else
say("Unable to continue production, power grid overload.")
say("Unable to continue production, no APC in area.")
finalize_build()
return

var/is_stack = ispath(design.build_path, /obj/item/stack)
if(!materials.has_materials(materials_needed, material_cost_coefficient, is_stack ? items_remaining : 1))
say("Unable to continue production, missing materials.")
finalize_build()
return
materials.use_materials(materials_needed, material_cost_coefficient, is_stack ? items_remaining : 1)

Expand Down

0 comments on commit 7a9e37b

Please sign in to comment.