diff --git a/code/modules/paperwork/faxmachine.dm b/code/modules/paperwork/faxmachine.dm
index 20595722fa9..3935348dad1 100644
--- a/code/modules/paperwork/faxmachine.dm
+++ b/code/modules/paperwork/faxmachine.dm
@@ -3,6 +3,9 @@ GLOBAL_LIST_EMPTY(alldepartments)
GLOBAL_LIST_EMPTY(adminfaxes) //cache for faxes that have been sent to admins
+#define FAX_PRINT_COOLDOWN 30 SECONDS
+#define FAX_SEND_COOLDOWN 60 SECONDS
+
/obj/machinery/photocopier/faxmachine
name = "fax machine"
icon = 'icons/obj/library.dmi'
@@ -14,7 +17,7 @@ GLOBAL_LIST_EMPTY(adminfaxes) //cache for faxes that have been sent to admins
active_power_usage = 200 WATTS
layer = BELOW_OBJ_LAYER
- var/obj/item/card/id/scan = null // identification
+ var/obj/item/card/id/inserted_id
var/authenticated = 0
var/sendcooldown = 0 // to avoid spamming fax messages
var/print_cooldown = 0 //to avoid spamming printing complaints
@@ -35,159 +38,126 @@ GLOBAL_LIST_EMPTY(adminfaxes) //cache for faxes that have been sent to admins
GLOB.alldepartments |= department
/obj/machinery/photocopier/faxmachine/Destroy()
- QDEL_NULL(scan)
+ QDEL_NULL(inserted_id)
GLOB.allfaxes -= src
return ..()
-/obj/machinery/photocopier/faxmachine/attack_hand(mob/user as mob)
- user.set_machine(src)
+/obj/machinery/photocopier/faxmachine/attack_hand(mob/user)
+ if(inoperable(MAINT))
+ return
- var/dat = "Fax Machine
"
+ if(user.lying || user.is_ic_dead())
+ return
- var/scan_name
- if(scan)
- scan_name = scan.name
- else
- scan_name = "--------"
+ tgui_interact(user)
- dat += "Confirm Identity: [scan_name]
"
+/obj/machinery/photocopier/faxmachine/tgui_interact(mob/user, datum/tgui/ui)
+ ui = SStgui.try_update_ui(user, src, ui)
+ if(!ui)
+ ui = new(user, src, "Fax")
+ ui.set_autoupdate(TRUE)
+ ui.open()
- if(authenticated)
- dat += "{Log Out}"
- else
- dat += "{Log In}"
+/obj/machinery/photocopier/faxmachine/tgui_data(mob/user)
+ var/list/data = list(
+ "user" = user?.name,
+ "idCard" = inserted_id?.registered_name,
+ "authenticated" = check_access(inserted_id),
+ "paper" = copyitem?.name,
+ "printCooldown" = print_cooldown,
+ "canSend" = (world.time > sendcooldown ? TRUE : FALSE)
+ )
- dat += "