mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
* first * printer, tools, prefab, assemblies, power.dm(looks like so) * integrated circuit * input memory epv2 exonet node * input,manipulation,output,poweract * fixes * reagents fix * time * minor fixes * all errors fixed * bugfixes * prefab, tickers, camera, led, assembling bugs, * All except exonet node UI and led's * cameras, led and some exonet * 11 * 111 * lesser fixes. * botanic shit * icon * nobludgeon for debugger * gui, typos * gui, typos * dopil * smaller diff, rm template and node * mergefix * list fix * weakrefs * fixes * Clamp, crowbar, minor shit * fukken refs * exonet node refactor, put defines into defines. * dme upload * defines,helpers,exonet node, botanic * TRUE/FALSE and minors * datumfix * moved init to ss * quickfix * cryo runtime fix * datums quickfix * admins * minor fixes * fixes * refs,tools * printer * fixes * fixes * check interactivity redo. * usercheck, fixes * weakrefs * T/F * WEAKREF * unfuckup * fixes and shit * Update assemblies.dm * crypto * fuck * SS, final fixes * looks like final fixes. * release,crypto, ranged scnner * defines * Resets some files * find/replace * Associative addresses * Update exonet_node.dm * push * there we go * fix * FINISH! * WEAKREFUCK * FixeS * Woops * Woops * woops * fix * fixes * loops * fix or break? * fix,dammit! * fix,dammit![2] * fix,dammit![3] * disconnect * fix * input * lag * pin * map * sdegsds * >>>lights * fixes le map * makes circuits actually speak * halffix * resets maps to tgstation master * typeless loops in init * Changes subsystem to not initialize new types and use initial instead. * fix * trying to get rid of obj list. * get rid of . * Better code makes better mind * fixed * pin fixes * fix * compiled tgui * circuits config * spelling
198 lines
5.9 KiB
Plaintext
198 lines
5.9 KiB
Plaintext
/*
|
|
Pins both hold data for circuits, as well move data between them. Some also cause circuits to do their function. DATA_CHANNEL pins are the data holding/moving kind,
|
|
where as PULSE_CHANNEL causes circuits to work() when their pulse hits them.
|
|
|
|
|
|
A visualization of how pins work is below. Imagine the below image involves an addition circuit.
|
|
When the bottom pin, the activator, receives a pulse, all the numbers on the left (input) get added, and the answer goes on the right side (output).
|
|
|
|
Inputs Outputs
|
|
|
|
A [2]\ /[8] result
|
|
B [1]-\|++|/
|
|
C [4]-/|++|
|
|
D [1]/ ||
|
|
||
|
|
Activator
|
|
|
|
|
|
|
|
*/
|
|
/datum/integrated_io
|
|
var/name = "input/output"
|
|
var/obj/item/integrated_circuit/holder
|
|
var/datum/weakref/data // This is a weakref, to reduce typecasts. Note that oftentimes numbers and text may also occupy this.
|
|
var/list/linked = list()
|
|
var/io_type = DATA_CHANNEL
|
|
|
|
/datum/integrated_io/New(newloc, name1, new_data)
|
|
name = name1
|
|
if(new_data)
|
|
data = new_data
|
|
holder = newloc
|
|
if(!istype(holder))
|
|
message_admins("ERROR: An integrated_io ([name]) spawned without a valid holder! This is a bug.")
|
|
|
|
/datum/integrated_io/Destroy()
|
|
disconnect()
|
|
data = null
|
|
holder = null
|
|
return ..()
|
|
/*
|
|
/datum/integrated_io/nano_host()
|
|
return holder.nano_host()
|
|
*/
|
|
|
|
/datum/integrated_io/proc/data_as_type(var/as_type)
|
|
if(!isweakref(data))
|
|
return
|
|
var/datum/weakref/w = data
|
|
var/output = w.resolve()
|
|
return istype(output, as_type) ? output : null
|
|
|
|
/datum/integrated_io/proc/display_data(var/input)
|
|
if(isnull(input))
|
|
return "(null)" // Empty data means nothing to show.
|
|
|
|
if(istext(input))
|
|
return "(\"[input]\")" // Wraps the 'string' in escaped quotes, so that people know it's a 'string'.
|
|
|
|
/*
|
|
list[](
|
|
"A",
|
|
"B",
|
|
"C"
|
|
)
|
|
*/
|
|
|
|
if(islist(input))
|
|
var/list/my_list = input
|
|
var/result = "list\[[my_list.len]\]("
|
|
if(my_list.len)
|
|
result += "<br>"
|
|
var/pos = 0
|
|
for(var/line in my_list)
|
|
result += "[display_data(line)]"
|
|
pos++
|
|
if(pos != my_list.len)
|
|
result += ",<br>"
|
|
result += "<br>"
|
|
result += ")"
|
|
return result
|
|
|
|
if(isweakref(input))
|
|
var/datum/weakref/w = input
|
|
var/atom/A = w.resolve()
|
|
return A ? "([A.name] \[Ref\])" : "(null)" // For refs, we want just the name displayed.
|
|
//return A ? "([REF(A)] \[Ref\])" : "(null)"
|
|
|
|
return "([input])" // Nothing special needed for numbers or other stuff.
|
|
|
|
/datum/integrated_io/activate/display_data()
|
|
return "(\[pulse\])"
|
|
|
|
/datum/integrated_io/proc/display_pin_type()
|
|
return IC_FORMAT_ANY
|
|
|
|
/datum/integrated_io/activate/display_pin_type()
|
|
return IC_FORMAT_PULSE
|
|
|
|
/datum/integrated_io/proc/scramble()
|
|
if(isnull(data))
|
|
return
|
|
if(isnum(data))
|
|
write_data_to_pin(rand(-10000, 10000))
|
|
if(istext(data))
|
|
write_data_to_pin("ERROR")
|
|
push_data()
|
|
|
|
/datum/integrated_io/activate/scramble()
|
|
push_data()
|
|
|
|
/datum/integrated_io/proc/write_data_to_pin(var/new_data)
|
|
if(isnull(new_data) || isnum(new_data) || istext(new_data) || isweakref(new_data))
|
|
data = new_data
|
|
holder.on_data_written()
|
|
else if(islist(new_data))
|
|
var/list/new_list = new_data
|
|
data = new_list.Copy(1,min( IC_MAX_LIST_LENGTH+1, new_list.len ))
|
|
holder.on_data_written()
|
|
|
|
/datum/integrated_io/proc/push_data()
|
|
for(var/k in 1 to linked.len)
|
|
var/datum/integrated_io/io = linked[k]
|
|
io.write_data_to_pin(data)
|
|
|
|
/datum/integrated_io/activate/push_data()
|
|
for(var/k in 1 to linked.len)
|
|
var/datum/integrated_io/io = linked[k]
|
|
io.holder.check_then_do_work()
|
|
|
|
/datum/integrated_io/proc/pull_data()
|
|
for(var/k in 1 to linked.len)
|
|
var/datum/integrated_io/io = linked[k]
|
|
write_data_to_pin(io.data)
|
|
|
|
/datum/integrated_io/proc/get_linked_to_desc()
|
|
if(linked.len)
|
|
return "the [english_list(linked)]"
|
|
return "nothing"
|
|
|
|
/datum/integrated_io/proc/disconnect()
|
|
//First we iterate over everything we are linked to.
|
|
if(linked && linked.len)
|
|
for(var/i in 1 to linked.len)
|
|
var/datum/integrated_io/their_io = linked[i]
|
|
//While doing that, we iterate them as well, and disconnect ourselves from them.
|
|
if(their_io.linked.len && their_io.linked)
|
|
for(var/j in 1 to their_io.linked.len)
|
|
var/datum/integrated_io/their_linked_io = their_io.linked[j]
|
|
if(their_linked_io == src)
|
|
their_io.linked.Remove(src)
|
|
else
|
|
continue
|
|
//Now that we're removed from them, we gotta remove them from us.
|
|
linked.Remove(their_io)
|
|
|
|
/datum/integrated_io/proc/ask_for_data_type(mob/user, var/default, var/list/allowed_data_types = list("string","number","null"))
|
|
var/type_to_use = input("Please choose a type to use.","[src] type setting") as null|anything in allowed_data_types
|
|
if(!holder.check_interactivity(user))
|
|
return
|
|
|
|
var/new_data = null
|
|
switch(type_to_use)
|
|
if("string")
|
|
new_data = input("Now type in a string.","[src] string writing", istext(default) ? default : null) as null|text
|
|
if(istext(new_data) && holder.check_interactivity(user) )
|
|
to_chat(user, "<span class='notice'>You input "+new_data+" into the pin.</span>")
|
|
return new_data
|
|
if("number")
|
|
new_data = input("Now type in a number.","[src] number writing", isnum(default) ? default : null) as null|num
|
|
if(isnum(new_data) && holder.check_interactivity(user) )
|
|
to_chat(user, "<span class='notice'>You input [new_data] into the pin.</span>")
|
|
return new_data
|
|
if("null")
|
|
if(holder.check_interactivity(user))
|
|
to_chat(user, "<span class='notice'>You clear the pin's memory.</span>")
|
|
return new_data
|
|
|
|
// Basically a null check
|
|
/datum/integrated_io/proc/is_valid()
|
|
return !isnull(data)
|
|
|
|
// This proc asks for the data to write, then writes it.
|
|
/datum/integrated_io/proc/ask_for_pin_data(mob/user)
|
|
var/new_data = ask_for_data_type(user)
|
|
write_data_to_pin(new_data)
|
|
|
|
/datum/integrated_io/activate/ask_for_pin_data(mob/user) // This just pulses the pin.
|
|
holder.check_then_do_work(ignore_power = TRUE)
|
|
to_chat(user, "<span class='notice'>You pulse \the [holder]'s [src] pin.</span>")
|
|
|
|
/datum/integrated_io/activate
|
|
name = "activation pin"
|
|
io_type = PULSE_CHANNEL
|
|
|
|
/datum/integrated_io/activate/out // All this does is just make the UI say 'out' instead of 'in'
|
|
data = 1
|