From 1acce5dc592fb4c61a5ff60d6430d4b1d89f1604 Mon Sep 17 00:00:00 2001 From: D Anzorge Date: Tue, 3 Feb 2015 11:20:46 -0500 Subject: [PATCH] Add cash purchases to vending machines --- code/game/machinery/vending.dm | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/code/game/machinery/vending.dm b/code/game/machinery/vending.dm index 205caf275f3..7698d2414c0 100644 --- a/code/game/machinery/vending.dm +++ b/code/game/machinery/vending.dm @@ -182,7 +182,34 @@ currently_vending = null else usr << "\icon[src]Your chargecard does not have enough money!" - + + // we shouldn't hit spacewallets by now since they were handled above, so this is cash only + else if (istype(W, /obj/item/weapon/spacecash) && currently_vending) + var/obj/item/weapon/spacecash/C = W + if(C.worth >= currently_vending.price) + if(istype(C, /obj/item/weapon/spacecash/bundle)) + visible_message("[usr] inserts some cash into [src].") + C.worth -= currently_vending.price + if(!C.worth) + usr.drop_from_inventory(W) + del(W) + else + W.update_icon() + else + // Non-bundles are whole bills. We eat the whole cash item and spit out change + visible_message("[usr] inserts a bill into [src].") + var/left = C.worth - currently_vending.price + + usr.drop_from_inventory(W) + del(W) + if(left) + spawn_money(left, src.loc, user) + + src.vend(src.currently_vending, usr) + currently_vending = null + else + usr << "\icon[src]That is not enough money to cover the price!" + else if(istype(W, /obj/item/weapon/wrench)) if(do_after(user, 20)) @@ -310,7 +337,7 @@ if(src.currently_vending) var/dat = "
[vendorname]


" //display the name, and added a horizontal rule - dat += "Product selected: [currently_vending.product_name]
Charge: [currently_vending.price]

Please swipe a card to pay for the item.
" + dat += "Product selected: [currently_vending.product_name]
Charge: [currently_vending.price]

Please swipe a card or insert cash to pay for the item.
" dat += "Cancel" user << browse(dat, "window=vending") onclose(user, "")