Skip to content

Commit

Permalink
[MIRROR] Add ability to swap IDs inside computers (#1319)
Browse files Browse the repository at this point in the history
* Add ability to swap IDs inside computers (#81844)

* Add ability to swap IDs inside computers

* Update internal_computer.dm

---------

Co-authored-by: Interception&? <[email protected]>
Co-authored-by: Mal <[email protected]>
  • Loading branch information
3 people authored and StealsThePRs committed Mar 7, 2024
1 parent f80121f commit 721ea4f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
34 changes: 23 additions & 11 deletions code/modules/modular_computers/computers/item/computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -267,30 +267,34 @@

/**
* InsertID
* Attempt to insert the ID in either card slot.
* Attempt to insert the ID in either card slot, if ID is present - attempts swap
* Args:
* inserting_id - the ID being inserted
* user - The person inserting the ID
*/
/obj/item/modular_computer/InsertID(obj/item/card/inserting_id, mob/user)
//all slots taken
if(computer_id_slot)
if(!isnull(user) && !user.transferItemToLoc(inserting_id, src))
return FALSE

if(user)
if(!user.transferItemToLoc(inserting_id, src))
return FALSE
to_chat(user, span_notice("You insert \the [inserting_id] into the card slot."))
else
inserting_id.forceMove(src)

if(!isnull(computer_id_slot))
RemoveID(user, silent = TRUE)

computer_id_slot = inserting_id

if(!isnull(user))
to_chat(user, span_notice("You insert \the [inserting_id] into the card slot."))
balloon_alert(user, "inserted ID")

playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)

if(ishuman(loc))
var/mob/living/carbon/human/human_wearer = loc
if(human_wearer.wear_id == src)
human_wearer.sec_hud_set_ID()

update_appearance()
update_slot_icon()
SEND_SIGNAL(src, COMSIG_MODULAR_COMPUTER_INSERTED_ID, inserting_id, user)
Expand All @@ -300,8 +304,9 @@
* Removes the ID card from the computer, and puts it in loc's hand if it's a mob
* Args:
* user - The mob trying to remove the ID, if there is one
* silent - Boolean, determines whether fluff text would be printed
*/
/obj/item/modular_computer/RemoveID(mob/user)
/obj/item/modular_computer/RemoveID(mob/user, silent = FALSE)
if(!computer_id_slot)
return ..()

Expand All @@ -314,14 +319,17 @@
computer_id_slot.forceMove(drop_location())

computer_id_slot = null
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)
balloon_alert(user, "removed ID")
to_chat(user, span_notice("You remove the card from the card slot."))

if(!silent && !isnull(user))
to_chat(user, span_notice("You remove the card from the card slot."))
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)
balloon_alert(user, "removed ID")

if(ishuman(loc))
var/mob/living/carbon/human/human_wearer = loc
if(human_wearer.wear_id == src)
human_wearer.sec_hud_set_ID()

update_slot_icon()
update_appearance()
return TRUE
Expand Down Expand Up @@ -403,6 +411,10 @@
/obj/item/modular_computer/add_context(atom/source, list/context, obj/item/held_item, mob/living/user)
. = ..()

if(computer_id_slot && isidcard(held_item))
context[SCREENTIP_CONTEXT_LMB] = "Swap ID"
. = CONTEXTUAL_SCREENTIP_SET

if(held_item?.tool_behaviour == TOOL_SCREWDRIVER && internal_cell)
context[SCREENTIP_CONTEXT_RMB] = "Remove Cell"
. = CONTEXTUAL_SCREENTIP_SET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
else
computer_id_slot = null

/obj/item/modular_computer/pda/synth/RemoveID(mob/user)
/obj/item/modular_computer/pda/synth/RemoveID(mob/user, silent = FALSE)
return

/obj/item/modular_computer/pda/synth/get_ntnet_status()
Expand Down

0 comments on commit 721ea4f

Please sign in to comment.