@@ -203,6 +203,9 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C
203203 // / used for narcing on underages
204204 var /obj /item/radio/alertradio
205205
206+ // / payout account (weakref) for custom items
207+ var /datum /weakref/custom_payout_account
208+
206209/ obj / item/ circuitboard
207210 // /determines if the circuit board originated from a vendor off station or not.
208211 var /onstation = TRUE
@@ -288,6 +291,17 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C
288291 return
289292 set_light (powered() ? MINIMUM_USEFUL_LIGHT_RANGE : 0 )
290293
294+ / obj / machinery/ vending/ update_desc()
295+ . = .. ()
296+ desc = initial(desc)
297+ if (custom_payout_account)
298+ var /datum /bank_account/account = custom_payout_account. resolve()
299+ if (istype(account))
300+ desc += " \n "
301+ desc += span_notice(" Custom orders are paid out to <b>[ account. account_holder] </b>." )
302+ desc += " \n "
303+ desc += span_notice(" Custom orders are priced at <b>[ chef_price] </b> credits." )
304+
291305/ obj / machinery/ vending/ update_icon_state()
292306 if (stat & BROKEN )
293307 icon_state = " [ initial(icon_state)] -broken"
@@ -657,6 +671,28 @@ GLOBAL_LIST_EMPTY(vending_products)
657671 P. amount++
658672 loaded_items++
659673
674+ if (custom_payout_account && custom_payout_account. resolve())
675+ return
676+
677+ var /obj /item/card/id/id_card = user. get_idcard()
678+ if (! istype(id_card))
679+ return
680+
681+ var /datum /bank_account/account = id_card. registered_account
682+ if (! istype(account))
683+ return
684+
685+ custom_payout_account = WEAKREF (account)
686+ // at the time of writing, tgui_input_number is nonfunctional
687+ // 10s timeout so people cant change price while a customer is shopping
688+ tgui_input_text_async (user, " Set a price for custom items (1-9999)" , " Custom Price" , " 10" , 4 , FALSE , CALLBACK (src , PROC_REF (chef_price_update)), 10 SECONDS )
689+
690+ / obj / machinery/ vending/ proc / chef_price_update(entry)
691+ var /input_text = text2num(entry)
692+ if (isnum(input_text) && input_text >= 1 && input_text <= 9999 )
693+ chef_price = input_text
694+ update_desc ()
695+
660696/ obj / machinery/ vending/ exchange_parts( mob / user, obj / item/ storage/ part_replacer/ W)
661697 if (! istype(W))
662698 return FALSE
@@ -884,7 +920,7 @@ GLOBAL_LIST_EMPTY(vending_products)
884920 vend_ready = FALSE // One thing at a time!!
885921
886922 // Charge the user
887- if (! charge_user(chef_price, P. full_name, FALSE ))
923+ if (! charge_user(chef_price, P. full_name, TRUE , TRUE ))
888924 vend_ready = TRUE
889925 return
890926
@@ -905,7 +941,7 @@ GLOBAL_LIST_EMPTY(vending_products)
905941 * Charge the user during a vend
906942 * Returns false if the user could not buy this item
907943 */
908- / obj / machinery/ vending/ proc / charge_user(price, item_name, always_charge)
944+ / obj / machinery/ vending/ proc / charge_user(price, item_name, always_charge, pay_custom = FALSE )
909945 var /mob /living/L
910946 if (isliving(usr ))
911947 L = usr
@@ -929,9 +965,15 @@ GLOBAL_LIST_EMPTY(vending_products)
929965 say (" You do not possess the funds to purchase \the [ item_name] ." )
930966 flick (icon_deny,src )
931967 return FALSE
932- var /datum /bank_account/D = SSeconomy. get_dep_account(payment_department)
933- if (D)
934- D. adjust_money(price)
968+ if (pay_custom)
969+ var /datum /bank_account/custom_account = custom_payout_account. resolve()
970+ if (istype(custom_account))
971+ custom_account. adjust_money(price)
972+ custom_account. bank_card_talk(" \A [ item_name] was purchased for [ price] credits!" )
973+ else
974+ var /datum /bank_account/D = SSeconomy. get_dep_account(payment_department)
975+ if (D)
976+ D. adjust_money(price)
935977
936978 return TRUE
937979
0 commit comments