Makes the coinpress respect inventory limits (#15202)

Co-authored-by: joep van der velden <15887760+farie82@users.noreply.github.com>
This commit is contained in:
Farie82
2021-02-21 22:43:38 +01:00
committed by GitHub
parent 4da7ebb4a7
commit 89824404da
+17 -9
View File
@@ -81,8 +81,11 @@
updateUsrDialog()
return
while(coinsToProduce > 0 && materials.use_amount_type(coin_mat, chosen))
create_coins(M.coin_type)
while(coinsToProduce > 0 && materials.can_use_amount(coin_mat, chosen))
if(!create_coins(M.coin_type))
visible_message("<span class='notice'>[src] stops printing to prevent an overflow.</span>")
break
materials.use_amount_type(coin_mat, chosen)
coinsToProduce--
newCoins++
updateUsrDialog()
@@ -95,10 +98,15 @@
/obj/machinery/mineral/mint/proc/create_coins(P)
var/turf/T = get_step(src,output_dir)
if(T)
var/obj/item/O = new P(src)
var/obj/item/storage/bag/money/M = locate(/obj/item/storage/bag/money, T)
if(!M)
M = new /obj/item/storage/bag/money(src)
unload_mineral(M)
O.forceMove(M)
if(!T)
return FALSE
var/obj/item/O = new P(src)
var/obj/item/storage/bag/money/M = locate(/obj/item/storage/bag/money, T)
if(!M)
M = new /obj/item/storage/bag/money(src)
unload_mineral(M)
else if(!M.can_be_inserted(O, FALSE)) // First coin will always fit. But will the Xth?
qdel(O)
return FALSE
O.forceMove(M)
return TRUE