mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 13:38:41 +01:00
[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.
This commit is contained in:
@@ -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, "<span class='notice'>You set \the [src]'s memory to \"[new_data]\".</span>")
|
||||
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, "<span class='notice'>You set \the [src]'s memory to [new_data].</span>")
|
||||
if("ref")
|
||||
accepting_refs = TRUE
|
||||
copy_values = FALSE
|
||||
to_chat(user, "<span class='notice'>You turn \the [src]'s ref scanner on. Slide it across \
|
||||
an object for a ref of that object to save it in memory.</span>")
|
||||
if("copy")
|
||||
accepting_refs = FALSE
|
||||
copy_values = TRUE
|
||||
to_chat(user, "<span class='notice'>You turn \the [src]'s value copier on. Use it on a pin \
|
||||
to save its current value in memory.</span>")
|
||||
if("null")
|
||||
data_to_write = null
|
||||
copy_values = FALSE
|
||||
to_chat(user, "<span class='notice'>You set \the [src]'s memory to absolutely nothing.</span>")
|
||||
|
||||
/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, "<span class='notice'>You let the debugger copy the data.</span>")
|
||||
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, "<span class='notice'>You write '[data_to_write ? data_to_show : "NULL"]' to the '[io]' pin of \the [io.holder].</span>")
|
||||
|
||||
//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, "<span class='notice'>You pulse \the [io.holder]'s [io].</span>")
|
||||
|
||||
@@ -137,13 +137,13 @@
|
||||
if(!cloning)
|
||||
HTML += " <A href='?src=[REF(src)];print=load'>{Load Program}</a> "
|
||||
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 += " <A href='?src=[REF(src)];print=cancel'>{Cancel Print}</a>"
|
||||
HTML += " <A href='?src=[REF(src)];print=cancel'>Cancel Print</a>"
|
||||
else
|
||||
HTML += " <A href='?src=[REF(src)];print=print'>{[fast_clone ? "Print" : "Begin Printing"] Assembly}</a>"
|
||||
HTML += " <A href='?src=[REF(src)];print=print'>[fast_clone ? "Print" : "Begin Printing"] Assembly</a>"
|
||||
|
||||
HTML += "<br><hr>"
|
||||
HTML += "Categories:"
|
||||
@@ -164,9 +164,9 @@
|
||||
if((initial(IC.spawn_flags) & IC_SPAWN_RESEARCH) && (!(initial(IC.spawn_flags) & IC_SPAWN_DEFAULT)) && !upgraded)
|
||||
can_build = FALSE
|
||||
if(can_build)
|
||||
HTML += "<A href='?src=[REF(src)];build=[path]'>\[[initial(O.name)]\]</A>: [initial(O.desc)]<br>"
|
||||
HTML += "<a href='?src=[REF(src)];build=[path]'>[initial(O.name)]</a>: [initial(O.desc)]<br>"
|
||||
else
|
||||
HTML += "<s>\[[initial(O.name)]\]</s>: [initial(O.desc)]<br>"
|
||||
HTML += "<s>[initial(O.name)]</s>: [initial(O.desc)]<br>"
|
||||
|
||||
popup.set_content(HTML)
|
||||
popup.open()
|
||||
|
||||
@@ -11,4 +11,14 @@
|
||||
holder.on_data_written()
|
||||
|
||||
/datum/integrated_io/ref/display_pin_type()
|
||||
return IC_FORMAT_REF
|
||||
return IC_FORMAT_REF
|
||||
|
||||
/datum/integrated_io/ref/connect_pin(datum/integrated_io/pin)
|
||||
..(pin)
|
||||
if(istype(pin,/datum/integrated_io/selfref))
|
||||
write_data_to_pin(pin.data)
|
||||
|
||||
/datum/integrated_io/ref/disconnect_pin(datum/integrated_io/pin)
|
||||
..(pin)
|
||||
if(istype(pin,/datum/integrated_io/selfref))
|
||||
write_data_to_pin(null)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// This pin only contains its own weakref and can't be changed
|
||||
/datum/integrated_io/selfref
|
||||
name = "selfref pin"
|
||||
|
||||
/datum/integrated_io/selfref/New()
|
||||
..()
|
||||
write_data_to_pin(src)
|
||||
|
||||
/datum/integrated_io/selfref/ask_for_pin_data(mob/user) // You can't clear it, it's self reference.
|
||||
|
||||
|
||||
/datum/integrated_io/selfref/write_data_to_pin(var/new_data) // You can't write anything else but itself onto it
|
||||
if(data)
|
||||
return
|
||||
data = WEAKREF(holder)
|
||||
holder.on_data_written()
|
||||
|
||||
/datum/integrated_io/selfref/display_pin_type()
|
||||
return IC_FORMAT_REF
|
||||
|
||||
/datum/integrated_io/selfref/connect_pin(datum/integrated_io/pin)
|
||||
pin.write_data_to_pin(data)
|
||||
..(pin)
|
||||
|
||||
/datum/integrated_io/selfref/disconnect_pin(datum/integrated_io/pin)
|
||||
..(pin)
|
||||
pin.write_data_to_pin(null)
|
||||
@@ -65,7 +65,7 @@
|
||||
)
|
||||
outputs = list(
|
||||
"volume used" = IC_PINTYPE_NUMBER,
|
||||
"self reference" = IC_PINTYPE_REF
|
||||
"self reference" = IC_PINTYPE_SELFREF
|
||||
)
|
||||
activators = list(
|
||||
"inject" = IC_PINTYPE_PULSE_IN,
|
||||
@@ -267,7 +267,7 @@
|
||||
inputs = list()
|
||||
outputs = list(
|
||||
"volume used" = IC_PINTYPE_NUMBER,
|
||||
"self reference" = IC_PINTYPE_REF
|
||||
"self reference" = IC_PINTYPE_SELFREF
|
||||
)
|
||||
activators = list("push ref" = IC_PINTYPE_PULSE_OUT)
|
||||
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
|
||||
@@ -314,7 +314,7 @@
|
||||
)
|
||||
outputs = list(
|
||||
"volume used" = IC_PINTYPE_NUMBER,
|
||||
"self reference" = IC_PINTYPE_REF
|
||||
"self reference" = IC_PINTYPE_SELFREF
|
||||
)
|
||||
activators = list(
|
||||
"grind" = IC_PINTYPE_PULSE_IN,
|
||||
@@ -361,7 +361,7 @@
|
||||
)
|
||||
outputs = list(
|
||||
"volume used" = IC_PINTYPE_NUMBER,
|
||||
"self reference" = IC_PINTYPE_REF
|
||||
"self reference" = IC_PINTYPE_SELFREF
|
||||
)
|
||||
activators = list(
|
||||
"juice" = IC_PINTYPE_PULSE_IN,
|
||||
@@ -406,7 +406,7 @@
|
||||
complexity = 8
|
||||
outputs = list(
|
||||
"volume used" = IC_PINTYPE_NUMBER,
|
||||
"self reference" = IC_PINTYPE_REF,
|
||||
"self reference" = IC_PINTYPE_SELFREF,
|
||||
"list of reagents" = IC_PINTYPE_LIST
|
||||
)
|
||||
activators = list(
|
||||
@@ -508,7 +508,7 @@
|
||||
"on" = IC_PINTYPE_BOOLEAN
|
||||
)
|
||||
inputs_default = list("1" = 300)
|
||||
outputs = list("volume used" = IC_PINTYPE_NUMBER,"self reference" = IC_PINTYPE_REF,"temperature" = IC_PINTYPE_NUMBER)
|
||||
outputs = list("volume used" = IC_PINTYPE_NUMBER,"self reference" = IC_PINTYPE_SELFREF,"temperature" = IC_PINTYPE_NUMBER)
|
||||
spawn_flags = IC_SPAWN_RESEARCH
|
||||
var/heater_coefficient = 0.1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user