diff --git a/code/modules/integrated_electronics/_defines.dm b/code/modules/integrated_electronics/_defines.dm
index a0b381f3a6c..017e7a1bf1d 100644
--- a/code/modules/integrated_electronics/_defines.dm
+++ b/code/modules/integrated_electronics/_defines.dm
@@ -242,11 +242,12 @@
var/list/linked = list()
var/io_type = DATA_CHANNEL
-/datum/integrated_io/New(var/newloc)
+/datum/integrated_io/New(var/newloc, var/name)
..()
+ src.name = name
holder = newloc
- if(!holder)
- message_admins("ERROR: An integrated_io ([src.name]) spawned without a holder! This is a bug.")
+ if(!istype(holder))
+ message_admins("ERROR: An integrated_io ([src.name]) spawned without a valid holder! This is a bug.")
/datum/integrated_io/Destroy()
disconnect()
@@ -270,9 +271,10 @@
return "(null)" // Empty data means nothing to show.
if(istext(data))
return "(\"[data]\")" // Wraps the 'string' in escaped quotes, so that people know it's a 'string'.
- if(istype(data, /atom))
- var/atom/A = data
- return "([A.name] \[Ref\])" // For refs, we want just the name displayed.
+ if(isweakref(data))
+ var/weakref/w = data
+ var/atom/A = w.resolve()
+ return A ? "([A.name] \[Ref\])" : "(null)" // For refs, we want just the name displayed.
return "([data])" // Nothing special needed for numbers or other stuff.
/datum/integrated_io/activate/display_data()
diff --git a/code/modules/integrated_electronics/tools.dm b/code/modules/integrated_electronics/tools.dm
index b0bc22cddcc..e996fae872e 100644
--- a/code/modules/integrated_electronics/tools.dm
+++ b/code/modules/integrated_electronics/tools.dm
@@ -137,7 +137,7 @@
/obj/item/device/integrated_electronics/debugger/afterattack(atom/target, mob/living/user, proximity)
if(accepting_refs && proximity)
- data_to_write = target
+ data_to_write = weakref(target)
visible_message("[user] slides \a [src]'s over \the [target].")
to_chat(user, "You set \the [src]'s memory to a reference to [target.name] \[Ref\]. The ref scanner is \
now off.")
@@ -146,7 +146,12 @@
/obj/item/device/integrated_electronics/debugger/proc/write_data(var/datum/integrated_io/io, mob/user)
if(io.io_type == DATA_CHANNEL)
io.write_data_to_pin(data_to_write)
- to_chat(user, "You write '[data_to_write ? data_to_write : "NULL"]' to the '[io]' pin of \the [io.holder].")
+ var/data_to_show = data_to_write
+ if(isweakref(data_to_write))
+ var/weakref/w = data_to_write
+ var/atom/A = w.resolve()
+ data_to_show = A.name
+ to_chat(user, "You write '[data_to_write ? data_to_show : "NULL"]' to the '[io]' pin of \the [io.holder].")
else if(io.io_type == PULSE_CHANNEL)
io.holder.check_then_do_work()
to_chat(user, "You pulse \the [io.holder]'s [io].")