From e183be5bb924c62c36ba379989bb30b3bf68d475 Mon Sep 17 00:00:00 2001
From: Shdorsh <32726535+Shdorsh@users.noreply.github.com>
Date: Sat, 8 Sep 2018 03:26:26 +0200
Subject: [PATCH] [READY] Making selfreferences finally reference themselves
(#40129)
[Changelogs]: # Hey folks, remember #39394 ? This is the continuation of it, in a much better and automated way. Besides, it was tested on my homeserver and it is fully functional. It also removes those horrid brackets from the printer interface and adds a copy data mode to the debugger, allowing you to copy any data and paste it in a pin accepting the same type.
cl Shdorsh
fix: Made the self reference pins for reagents reference themselves automatically.
tweak: Made it possible to copy datas frop pin to pin with the debugger.
spellcheck: Removed ugly useless brackets from printers.
/cl
[why]: # First, because that's what it was supposed to do. Secondly, it makes handling reagent circuitry easier. Thirdly, this gives new options for new circuits.
Tested and working.
---
code/__DEFINES/integrated_electronics.dm | 1 +
.../integrated_electronics/core/debugger.dm | 24 ++++++++++++++++-
.../integrated_electronics/core/printer.dm | 12 ++++-----
.../core/special_pins/ref_pin.dm | 12 ++++++++-
.../core/special_pins/selfref_pin.dm | 27 +++++++++++++++++++
.../subtypes/reagents.dm | 12 ++++-----
tgstation.dme | 1 +
7 files changed, 75 insertions(+), 14 deletions(-)
create mode 100644 code/modules/integrated_electronics/core/special_pins/selfref_pin.dm
diff --git a/code/__DEFINES/integrated_electronics.dm b/code/__DEFINES/integrated_electronics.dm
index 3647a61d773..727314abc6f 100644
--- a/code/__DEFINES/integrated_electronics.dm
+++ b/code/__DEFINES/integrated_electronics.dm
@@ -40,6 +40,7 @@
#define IC_PINTYPE_REF /datum/integrated_io/ref
#define IC_PINTYPE_LIST /datum/integrated_io/lists
#define IC_PINTYPE_INDEX /datum/integrated_io/index
+#define IC_PINTYPE_SELFREF /datum/integrated_io/selfref
#define IC_PINTYPE_PULSE_IN /datum/integrated_io/activate
#define IC_PINTYPE_PULSE_OUT /datum/integrated_io/activate/out
diff --git a/code/modules/integrated_electronics/core/debugger.dm b/code/modules/integrated_electronics/core/debugger.dm
index ceaee08fa15..5d414de5eea 100644
--- a/code/modules/integrated_electronics/core/debugger.dm
+++ b/code/modules/integrated_electronics/core/debugger.dm
@@ -9,9 +9,10 @@
w_class = WEIGHT_CLASS_SMALL
var/data_to_write = null
var/accepting_refs = FALSE
+ var/copy_values = FALSE
/obj/item/integrated_electronics/debugger/attack_self(mob/user)
- var/type_to_use = input("Please choose a type to use.","[src] type setting") as null|anything in list("string","number","ref", "null")
+ var/type_to_use = input("Please choose a type to use.","[src] type setting") as null|anything in list("string","number","ref","copy","null")
if(!user.IsAdvancedToolUser())
return
@@ -19,22 +20,31 @@
switch(type_to_use)
if("string")
accepting_refs = FALSE
+ copy_values = FALSE
new_data = stripped_input(user, "Now type in a string.","[src] string writing", no_trim = TRUE)
if(istext(new_data) && user.IsAdvancedToolUser())
data_to_write = new_data
to_chat(user, "You set \the [src]'s memory to \"[new_data]\".")
if("number")
accepting_refs = FALSE
+ copy_values = FALSE
new_data = input(user, "Now type in a number.","[src] number writing") as null|num
if(isnum(new_data) && user.IsAdvancedToolUser())
data_to_write = new_data
to_chat(user, "You set \the [src]'s memory to [new_data].")
if("ref")
accepting_refs = TRUE
+ copy_values = FALSE
to_chat(user, "You turn \the [src]'s ref scanner on. Slide it across \
an object for a ref of that object to save it in memory.")
+ if("copy")
+ accepting_refs = FALSE
+ copy_values = TRUE
+ to_chat(user, "You turn \the [src]'s value copier on. Use it on a pin \
+ to save its current value in memory.")
if("null")
data_to_write = null
+ copy_values = FALSE
to_chat(user, "You set \the [src]'s memory to absolutely nothing.")
/obj/item/integrated_electronics/debugger/afterattack(atom/target, mob/living/user, proximity)
@@ -47,14 +57,26 @@
accepting_refs = FALSE
/obj/item/integrated_electronics/debugger/proc/write_data(var/datum/integrated_io/io, mob/user)
+ //If the pin can take data:
if(io.io_type == DATA_CHANNEL)
+ //If the debugger is set to copy, copy the data in the pin onto it
+ if(copy_values)
+ data_to_write = io.data
+ to_chat(user, "You let the debugger copy the data.")
+ copy_values = FALSE
+ return
+
+ //Else, write the data to the pin
io.write_data_to_pin(data_to_write)
var/data_to_show = data_to_write
+ //This is only to convert a weakref into a name for better output
if(isweakref(data_to_write))
var/datum/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].")
+
+ //If the pin can only be pulsed
else if(io.io_type == PULSE_CHANNEL)
io.holder.check_then_do_work(io.ord,ignore_power = TRUE)
to_chat(user, "You pulse \the [io.holder]'s [io].")
diff --git a/code/modules/integrated_electronics/core/printer.dm b/code/modules/integrated_electronics/core/printer.dm
index 3470cef801b..de3ade389f2 100644
--- a/code/modules/integrated_electronics/core/printer.dm
+++ b/code/modules/integrated_electronics/core/printer.dm
@@ -137,13 +137,13 @@
if(!cloning)
HTML += " {Load Program} "
else
- HTML += " {Load Program}"
+ HTML += " Load Program"
if(!program)
- HTML += " {[fast_clone ? "Print" : "Begin Printing"] Assembly}"
+ HTML += " [fast_clone ? "Print" : "Begin Printing"] Assembly"
else if(cloning)
- HTML += " {Cancel Print}"
+ HTML += " Cancel Print"
else
- HTML += " {[fast_clone ? "Print" : "Begin Printing"] Assembly}"
+ HTML += " [fast_clone ? "Print" : "Begin Printing"] Assembly"
HTML += "