From 0b3d43667cc27f07cd6c0f189270c132c57b1327 Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Sun, 18 Aug 2013 00:56:49 -0700 Subject: [PATCH] Made vending machines less of a PITA. --- .../Cael_Aislinn/Economy/Accounts.dm | 4 +- code/game/machinery/vending.dm | 44 ++++++++++++++++--- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/code/WorkInProgress/Cael_Aislinn/Economy/Accounts.dm b/code/WorkInProgress/Cael_Aislinn/Economy/Accounts.dm index 3f069ced4e2..1e2e7f26337 100644 --- a/code/WorkInProgress/Cael_Aislinn/Economy/Accounts.dm +++ b/code/WorkInProgress/Cael_Aislinn/Economy/Accounts.dm @@ -347,10 +347,10 @@ var/global/datum/money_account/vendor_account return 0 //this returns the first account datum that matches the supplied accnum/pin combination, it returns null if the combination did not match any account -/obj/machinery/account_database/proc/attempt_account_access(var/attempt_account_number, var/attempt_pin_number, var/security_level_passed = 0) +/obj/machinery/account_database/proc/attempt_account_access(var/attempt_account_number, var/attempt_pin_number, var/security_level_passed = 0,var/pin_needed=1) if(!activated) return 0 for(var/datum/money_account/D in accounts) if(D.account_number == attempt_account_number) - if( D.security_level <= security_level_passed && (!D.security_level || D.remote_access_pin == attempt_pin_number) ) + if( D.security_level <= security_level_passed && (!D.security_level || D.remote_access_pin == attempt_pin_number || !pin_needed) ) return D diff --git a/code/game/machinery/vending.dm b/code/game/machinery/vending.dm index d98d57de30b..182714b895b 100644 --- a/code/game/machinery/vending.dm +++ b/code/game/machinery/vending.dm @@ -157,7 +157,26 @@ coin = W user << "\blue You insert the [W] into the [src]" return - else if(istype(W, /obj/item/weapon/card) && currently_vending) + /*else if(istype(W, /obj/item/weapon/card) && currently_vending) + //attempt to connect to a new db, and if that doesn't work then fail + if(!linked_db) + reconnect_database() + if(linked_db) + if(linked_account) + var/obj/item/weapon/card/I = W + scan_card(I) + else + usr << "\icon[src]Unable to connect to linked account." + else + usr << "\icon[src]Unable to connect to accounts database."*/ + else + ..() + +//H.wear_id +/obj/machinery/vending/proc/connect_account(var/obj/item/W) + if(istype(W,/obj/item/device/pda)) + W=W:id // Cheating, but it'll work. Hopefully. + if(istype(W, /obj/item/weapon/card) && currently_vending) //attempt to connect to a new db, and if that doesn't work then fail if(!linked_db) reconnect_database() @@ -169,8 +188,6 @@ usr << "\icon[src]Unable to connect to linked account." else usr << "\icon[src]Unable to connect to accounts database." - else - ..() /obj/machinery/vending/proc/scan_card(var/obj/item/weapon/card/I) if(!currently_vending) return @@ -178,8 +195,7 @@ var/obj/item/weapon/card/id/C = I visible_message("[usr] swipes a card through [src].") if(linked_account) - var/attempt_pin = input("Enter pin code", "Vendor transaction") as num - var/datum/money_account/D = linked_db.attempt_account_access(C.associated_account_number, attempt_pin, 2) + var/datum/money_account/D = linked_db.attempt_account_access(C.associated_account_number, 0, 2, 0) // Pin = 0, Sec level 2, PIN not required. if(D) var/transaction_amount = currently_vending.price if(transaction_amount <= D.money) @@ -229,6 +245,7 @@ /obj/machinery/vending/attack_hand(mob/user as mob) if(stat & (BROKEN|NOPOWER)) return + user.set_machine(src) if(src.seconds_electrified != 0) @@ -239,7 +256,8 @@ if(src.currently_vending) var/dat = "
[vendorname]


" //display the name, and added a horizontal rule - dat += "You have selected [currently_vending.product_name].
Please swipe your ID to pay for the article.

" + dat += "You have selected [currently_vending.product_name].
Please ensure your ID is in your ID holder or hand.

" + dat += "Pay | " dat += "Cancel" user << browse(dat, "window=vending") onclose(user, "") @@ -315,7 +333,7 @@ if(istype(usr,/mob/living/silicon)) if(istype(usr,/mob/living/silicon/robot)) var/mob/living/silicon/robot/R = usr - if(!(R.module && istype(R.module,/obj/item/weapon/robot_module/butler) )) + if(!(R.module && istype(R.module,/obj/item/weapon/robot_module/butler) ) && !isMoMMI(R)) usr << "\red The vending machine refuses to interface with you, as you are not in its target demographic!" return else @@ -360,6 +378,18 @@ src.updateUsrDialog() return + else if (href_list["buy"]) + if(istype(usr, /mob/living/carbon/human)) + var/mob/living/carbon/human/H=usr + var/obj/item/weapon/card/card = null + if(istype(H.wear_id,/obj/item/weapon/card)) + card=H.wear_id + else if(istype(H.get_active_hand(),/obj/item/weapon/card)) + card=H.wear_id + if(card) + connect_account(card) + return + else if ((href_list["cutwire"]) && (src.panel_open)) var/twire = text2num(href_list["cutwire"]) if (!( istype(usr.get_active_hand(), /obj/item/weapon/wirecutters) ))