mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Ports the Port of Circuits
Ports PsiOmegaDelta's port of integrated circuits, which has several improvements in code quality. Ports a few small things like the weakref datum and some macros.
This commit is contained in:
@@ -42,6 +42,10 @@
|
||||
|
||||
#define isxeno(A) istype(A, /mob/living/simple_animal/xeno)
|
||||
|
||||
#define isweakref(A) istype(A, /weakref)
|
||||
|
||||
#define RANDOM_BLOOD_TYPE pick(4;"O-", 36;"O+", 3;"A-", 28;"A+", 1;"B-", 20;"B+", 1;"AB-", 5;"AB+")
|
||||
|
||||
#define to_chat(target, message) target << message
|
||||
|
||||
#define CanInteract(user, state) (CanUseTopic(user, state) == STATUS_INTERACTIVE)
|
||||
|
||||
31
code/datums/weakref.dm
Normal file
31
code/datums/weakref.dm
Normal file
@@ -0,0 +1,31 @@
|
||||
/datum
|
||||
var/weakref/weakref
|
||||
|
||||
/datum/Destroy()
|
||||
weakref = null // Clear this reference to ensure it's kept for as brief duration as possible.
|
||||
. = ..()
|
||||
|
||||
//obtain a weak reference to a datum
|
||||
/proc/weakref(datum/D)
|
||||
if(D.gcDestroyed)
|
||||
return
|
||||
if(!D.weakref)
|
||||
D.weakref = new/weakref(D)
|
||||
return D.weakref
|
||||
|
||||
/weakref
|
||||
var/ref
|
||||
|
||||
/weakref/New(datum/D)
|
||||
ref = "\ref[D]"
|
||||
|
||||
/weakref/Destroy()
|
||||
// A weakref datum should not be manually destroyed as it is a shared resource,
|
||||
// rather it should be automatically collected by the BYOND GC when all references are gone.
|
||||
return 0
|
||||
|
||||
/weakref/proc/resolve()
|
||||
var/datum/D = locate(ref)
|
||||
if(D && D.weakref == src)
|
||||
return D
|
||||
return null
|
||||
@@ -630,3 +630,14 @@
|
||||
return ITEMSIZE_COST_HUGE
|
||||
else
|
||||
return ITEMSIZE_COST_NO_CONTAINER
|
||||
|
||||
/obj/item/weapon/storage/proc/make_exact_fit()
|
||||
storage_slots = contents.len
|
||||
|
||||
can_hold.Cut()
|
||||
max_w_class = 0
|
||||
max_storage_space = 0
|
||||
for(var/obj/item/I in src)
|
||||
can_hold[I.type]++
|
||||
max_w_class = max(I.w_class, max_w_class)
|
||||
max_storage_space += I.get_storage_cost()
|
||||
|
||||
@@ -47,7 +47,7 @@ var/list/hiss_sound = list('sound/voice/hiss1.ogg','sound/voice/hiss2.ogg','soun
|
||||
var/list/page_sound = list('sound/effects/pageturn1.ogg', 'sound/effects/pageturn2.ogg','sound/effects/pageturn3.ogg')
|
||||
//var/list/gun_sound = list('sound/weapons/Gunshot.ogg', 'sound/weapons/Gunshot2.ogg','sound/weapons/Gunshot3.ogg','sound/weapons/Gunshot4.ogg')
|
||||
|
||||
/proc/playsound(var/atom/source, soundin, vol as num, vary, extrarange as num, falloff, var/is_global)
|
||||
/proc/playsound(var/atom/source, soundin, vol as num, vary, extrarange as num, falloff, var/is_global, var/frequency)
|
||||
|
||||
soundin = get_sfx(soundin) // same sound for everyone
|
||||
|
||||
@@ -55,7 +55,7 @@ var/list/page_sound = list('sound/effects/pageturn1.ogg', 'sound/effects/pagetur
|
||||
error("[source] is an area and is trying to make the sound: [soundin]")
|
||||
return
|
||||
|
||||
var/frequency = get_rand_frequency() // Same frequency for everybody
|
||||
frequency = isnull(frequency) ? get_rand_frequency() : frequency // Same frequency for everybody
|
||||
var/turf/turf_source = get_turf(source)
|
||||
|
||||
// Looping through the player list has the added bonus of working for mobs inside containers
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#define IC_INPUT "input"
|
||||
#define IC_OUTPUT "output"
|
||||
#define IC_ACTIVATOR "activator"
|
||||
|
||||
#define DATA_CHANNEL "data channel"
|
||||
#define PULSE_CHANNEL "pulse channel"
|
||||
|
||||
@@ -11,66 +15,37 @@
|
||||
var/list/inputs = list()
|
||||
var/list/outputs = list()
|
||||
var/list/activators = list()
|
||||
var/number_of_inputs = 0 //This is how many input pins are created
|
||||
var/number_of_outputs = 0 //Likewise for output
|
||||
var/number_of_activators = 0 //Guess
|
||||
var/list/input_names = list()
|
||||
var/list/output_names = list()
|
||||
var/list/activator_names = list()
|
||||
var/last_used = 0 //Uses world.time
|
||||
var/next_use = 0 //Uses world.time
|
||||
var/complexity = 1 //This acts as a limitation on building machines, more resource-intensive components cost more 'space'.
|
||||
var/cooldown_per_use = 2 SECONDS
|
||||
var/cooldown_per_use = 1 SECOND
|
||||
var/category = /obj/item/integrated_circuit // Used by the toolsets to filter out category types
|
||||
|
||||
/obj/item/integrated_circuit/examine(mob/user)
|
||||
..()
|
||||
user << "This board has [inputs.len] input [inputs.len != 1 ? "pins" : "pin"] and \
|
||||
[outputs.len] output [outputs.len != 1 ? "pins" : "pin"]."
|
||||
to_chat(user, "This board has [inputs.len] input pin\s and [outputs.len] output pin\s.")
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
if(I.linked.len)
|
||||
user << "\The [I.name] is connected to [I.get_linked_to_desc()]."
|
||||
to_chat(user, "The [I] is connected to [I.get_linked_to_desc()].")
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
if(O.linked.len)
|
||||
user << "\The [O.name] is connected to [O.get_linked_to_desc()]."
|
||||
to_chat(user, "The [O] is connected to [O.get_linked_to_desc()].")
|
||||
for(var/datum/integrated_io/activate/A in activators)
|
||||
if(A.linked.len)
|
||||
user << "\The [A.name] is connected to [A.get_linked_to_desc()]."
|
||||
to_chat(user, "The [A] is connected to [A.get_linked_to_desc()].")
|
||||
|
||||
interact(user)
|
||||
|
||||
/obj/item/integrated_circuit/New()
|
||||
setup_io(inputs, /datum/integrated_io/input)
|
||||
setup_io(outputs, /datum/integrated_io/output)
|
||||
setup_io(activators, /datum/integrated_io/activate)
|
||||
..()
|
||||
var/i = 0
|
||||
if(number_of_inputs)
|
||||
for(i = number_of_inputs, i > 0, i--)
|
||||
inputs.Add(new /datum/integrated_io/input(src))
|
||||
|
||||
if(number_of_outputs)
|
||||
for(i = number_of_outputs, i > 0, i--)
|
||||
outputs.Add(new /datum/integrated_io/output(src))
|
||||
|
||||
if(number_of_activators)
|
||||
for(i = number_of_activators, i > 0, i--)
|
||||
activators.Add(new /datum/integrated_io/activate(src))
|
||||
|
||||
apply_names_to_io()
|
||||
|
||||
/obj/item/integrated_circuit/proc/apply_names_to_io()
|
||||
var/i = 1
|
||||
if(input_names.len)
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.name = "[input_names[i]]"
|
||||
i++
|
||||
i = 1
|
||||
if(output_names.len)
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
O.name = "[output_names[i]]"
|
||||
i++
|
||||
|
||||
i = 1
|
||||
if(activator_names.len)
|
||||
for(var/datum/integrated_io/activate/A in activators)
|
||||
A.name = "[activator_names[i]]"
|
||||
i++
|
||||
/obj/item/integrated_circuit/proc/setup_io(var/list/io_list, var/io_type)
|
||||
var/list/names = io_list.Copy()
|
||||
io_list.Cut()
|
||||
for(var/name in names)
|
||||
io_list.Add(new io_type(src, name))
|
||||
|
||||
/obj/item/integrated_circuit/proc/on_data_written() //Override this for special behaviour when new data gets pushed to the circuit.
|
||||
return
|
||||
@@ -82,7 +57,12 @@
|
||||
qdel(O)
|
||||
for(var/datum/integrated_io/A in activators)
|
||||
qdel(A)
|
||||
..()
|
||||
. = ..()
|
||||
|
||||
/obj/item/integrated_circuit/nano_host()
|
||||
if(istype(src.loc, /obj/item/device/electronic_assembly))
|
||||
return loc
|
||||
return ..()
|
||||
|
||||
/obj/item/integrated_circuit/emp_act(severity)
|
||||
for(var/datum/integrated_io/io in inputs + outputs + activators)
|
||||
@@ -94,42 +74,42 @@
|
||||
set desc = "Rename your circuit, useful to stay organized."
|
||||
|
||||
var/mob/M = usr
|
||||
|
||||
if(!M.canmove || M.stat || M.restrained())
|
||||
if(!CanInteract(M, physical_state))
|
||||
return
|
||||
|
||||
var/input = sanitizeSafe(input("What do you want to name the circuit?", "Rename", src.name), MAX_NAME_LEN)
|
||||
|
||||
if(src && input)
|
||||
M << "<span class='notice'>The circuit '[src.name]' is now labeled '[input]'.</span>"
|
||||
var/input = sanitizeSafe(input("What do you want to name the circuit?", "Rename", src.name) as null|text, MAX_NAME_LEN)
|
||||
if(src && input && CanInteract(M, physical_state))
|
||||
to_chat(M, "<span class='notice'>The circuit '[src.name]' is now labeled '[input]'.</span>")
|
||||
name = input
|
||||
|
||||
/obj/item/integrated_circuit/proc/get_pin_ref(var/pin_type, var/pin_number)
|
||||
switch(pin_type)
|
||||
if("input")
|
||||
if(IC_INPUT)
|
||||
if(pin_number > inputs.len)
|
||||
return null
|
||||
return inputs[pin_number]
|
||||
if("output")
|
||||
if(IC_OUTPUT)
|
||||
if(pin_number > outputs.len)
|
||||
return null
|
||||
return outputs[pin_number]
|
||||
if("activator")
|
||||
if(IC_ACTIVATOR)
|
||||
if(pin_number > activators.len)
|
||||
return null
|
||||
return activators[pin_number]
|
||||
return null
|
||||
|
||||
/obj/item/integrated_circuit/interact(mob/user)
|
||||
if(get_dist(get_turf(src), user) > 1)
|
||||
user.unset_machine(src)
|
||||
if(!CanInteract(user, physical_state))
|
||||
return
|
||||
var/HTML = "<html><head><title>[src.name]</title></head><body>"
|
||||
|
||||
var/HTML = list()
|
||||
HTML += "<html><head><title>[src.name]</title></head><body>"
|
||||
HTML += "<div align='center'>"
|
||||
HTML += "<table border='1' style='undefined;table-layout: fixed; width: 424px'>"
|
||||
|
||||
HTML += "<br><a href='?src=\ref[src];user=\ref[user]'>\[Refresh\]</a> | "
|
||||
HTML += "<a href='?src=\ref[src];user=\ref[user];rename=1'>\[Rename\]</a><br>"
|
||||
HTML += "<br><a href='?src=\ref[src];'>\[Refresh\]</a> | "
|
||||
HTML += "<a href='?src=\ref[src];rename=1'>\[Rename\]</a> | "
|
||||
HTML += "<a href='?src=\ref[src];remove=1'>\[Remove\]</a><br>"
|
||||
|
||||
HTML += "<colgroup>"
|
||||
HTML += "<col style='width: 121px'>"
|
||||
@@ -139,79 +119,68 @@
|
||||
|
||||
var/column_width = 3
|
||||
var/row_height = max(inputs.len, outputs.len, 1)
|
||||
var/i
|
||||
var/j
|
||||
for(i = 1, i < row_height+1, i++)
|
||||
|
||||
for(var/i = 1 to row_height)
|
||||
HTML += "<tr>"
|
||||
for(j = 1, j < column_width+1, j++)
|
||||
for(var/j = 1 to column_width)
|
||||
var/datum/integrated_io/io = null
|
||||
var/words = null
|
||||
var/words = list()
|
||||
var/height = 1
|
||||
switch(j)
|
||||
if(1)
|
||||
io = get_pin_ref("input",i)
|
||||
io = get_pin_ref(IC_INPUT, i)
|
||||
if(io)
|
||||
if(io.linked.len)
|
||||
words = "<a href=?src=\ref[src];wire=1;user=\ref[user];pin=\ref[io]><b>[io.name] [io.display_data()]</b></a><br>"
|
||||
words += "<a href=?src=\ref[src];wire=1;pin=\ref[io]><b>[io.name] [io.display_data()]</b></a><br>"
|
||||
for(var/datum/integrated_io/linked in io.linked)
|
||||
words += "<a href=?src=\ref[src];wire=1;user=\ref[user];pin=\ref[io]>\[[linked.name]\]</a> \
|
||||
@ <a href=?src=\ref[linked.holder];examine=1;user=\ref[user]>[linked.holder]</a><br>"
|
||||
else // "Click <a href=?src=\ref[src];action=start>here</a>!"
|
||||
words = "<a href=?src=\ref[src];wire=1;user=\ref[user];pin=\ref[io]>[io.name] [io.display_data()]</a><br>"
|
||||
words += "<a href=?src=\ref[src];wire=1;pin=\ref[io]>\[[linked.name]\]</a> \
|
||||
@ <a href=?src=\ref[linked.holder];examine=1;>[linked.holder]</a><br>"
|
||||
else
|
||||
words += "<a href=?src=\ref[src];wire=1;pin=\ref[io]>[io.name] [io.display_data()]</a><br>"
|
||||
for(var/datum/integrated_io/linked in io.linked)
|
||||
words += "<a href=?src=\ref[src];wire=1;user=\ref[user];pin=\ref[io]>\[[linked.name]\]</a> \
|
||||
@ <a href=?src=\ref[linked.holder];examine=1;user=\ref[user]>[linked.holder]</a><br>"
|
||||
words += "<a href=?src=\ref[src];wire=1;pin=\ref[io]>\[[linked.name]\]</a> \
|
||||
@ <a href=?src=\ref[linked.holder];examine=1;>[linked.holder]</a><br>"
|
||||
if(outputs.len > inputs.len)
|
||||
// height = Floor(outputs.len / inputs.len)
|
||||
height = 1 // Because of bugs, if there's more outputs than inputs, it causes the output side to be hidden.
|
||||
//world << "I wrote [words] at ([i],[j]). Height = [height]."
|
||||
height = 1
|
||||
if(2)
|
||||
if(i == 1)
|
||||
words = "[src.name]<br><br>[src.desc]"
|
||||
words += "[src.name]<br><br>[src.desc]"
|
||||
height = row_height
|
||||
//world << "I wrote the center piece because i was equal to 1, at ([i],[j]). Height = [height]."
|
||||
else
|
||||
continue
|
||||
if(3)
|
||||
io = get_pin_ref("output",i)
|
||||
io = get_pin_ref(IC_OUTPUT, i)
|
||||
if(io)
|
||||
if(io.linked.len)
|
||||
words = "<a href=?src=\ref[src];wire=1;user=\ref[user];pin=\ref[io]><b>[io.name] [io.display_data()]</b></a><br>"
|
||||
words += "<a href=?src=\ref[src];wire=1;pin=\ref[io]><b>[io.name] [io.display_data()]</b></a><br>"
|
||||
for(var/datum/integrated_io/linked in io.linked)
|
||||
words += "<a href=?src=\ref[src];wire=1;user=\ref[user];pin=\ref[io]>\[[linked.name]\]</a> \
|
||||
words += "<a href=?src=\ref[src];wire=1;pin=\ref[io]>\[[linked.name]\]</a> \
|
||||
@ <a href=?src=\ref[linked.holder];examine=1;user=\ref[user]>[linked.holder]</a><br>"
|
||||
else
|
||||
words = "<a href=?src=\ref[src];wire=1;user=\ref[user];pin=\ref[io]>[io.name] [io.display_data()]</a><br>"
|
||||
words += "<a href=?src=\ref[src];wire=1;pin=\ref[io]>[io.name] [io.display_data()]</a><br>"
|
||||
for(var/datum/integrated_io/linked in io.linked)
|
||||
words += "<a href=?src=\ref[src];wire=1;user=\ref[user];pin=\ref[io]>\[[linked.name]\]</a> \
|
||||
@ <a href=?src=\ref[linked.holder];examine=1;user=\ref[user]>[linked.holder]</a><br>"
|
||||
words += "<a href=?src=\ref[src];wire=1;pin=\ref[io]>\[[linked.name]\]</a> \
|
||||
@ <a href=?src=\ref[linked.holder];examine=1;>[linked.holder]</a><br>"
|
||||
if(inputs.len > outputs.len)
|
||||
// height = Floor(inputs.len / outputs.len)
|
||||
height = 1 // See above.
|
||||
//world << "I wrote [words] at ([i],[j]). Height = [height]."
|
||||
HTML += "<td align='center' rowspan='[height]'>[words]</td>"
|
||||
//HTML += "<td align='center'>[words]</td>"
|
||||
//world << "Writing to ([i],[j])."
|
||||
height = 1
|
||||
HTML += "<td align='center' rowspan='[height]'>[jointext(words, null)]</td>"
|
||||
HTML += "</tr>"
|
||||
|
||||
if(activators.len)
|
||||
for(i = 1, i < activators.len+1, i++)
|
||||
var/datum/integrated_io/io = null
|
||||
var/words = null
|
||||
io = get_pin_ref("activator",i)
|
||||
if(io)
|
||||
for(var/activator in activators)
|
||||
var/datum/integrated_io/io = activator
|
||||
var/words = list()
|
||||
if(io.linked.len)
|
||||
words = "<a href=?src=\ref[src];wire=1;user=\ref[user];pin=\ref[io]><font color='FF0000'><b>[io.name]</b></font></a><br>"
|
||||
words += "<a href=?src=\ref[src];wire=1;pin=\ref[io]><font color='FF0000'><b>[io.name]</b></font></a><br>"
|
||||
for(var/datum/integrated_io/linked in io.linked)
|
||||
words += "<a href=?src=\ref[src];wire=1;user=\ref[user];pin=\ref[io]>\[[linked.name]\]</a> \
|
||||
words += "<a href=?src=\ref[src];wire=1;pin=\ref[io]>\[[linked.name]\]</a> \
|
||||
@ <a href=?src[src];examine=1;user=\ref[user]>[linked.holder]</a><br>"
|
||||
else // "Click <a href=?src=\ref[src];action=start>here</a>!"
|
||||
words = "<a href=?src=\ref[src];wire=1;user=\ref[user];pin=\ref[io]><font color='FF0000'>[io.name]</font></a><br>"
|
||||
else
|
||||
words += "<a href=?src=\ref[src];wire=1;pin=\ref[io]><font color='FF0000'>[io.name]</font></a><br>"
|
||||
for(var/datum/integrated_io/linked in io.linked)
|
||||
words += "<a href=?src=\ref[src];wire=1;user=\ref[user];pin=\ref[io]>\[[linked.name]\]</a> \
|
||||
@ <a href=?src=\ref[linked.holder];examine=1;user=\ref[user]>[linked.holder]</a><br>"
|
||||
words += "<a href=?src=\ref[src];wire=1;pin=\ref[io]>\[[linked.name]\]</a> \
|
||||
@ <a href=?src=\ref[linked.holder];examine=1;>[linked.holder]</a><br>"
|
||||
HTML += "<tr>"
|
||||
HTML += "<td colspan='3' align='center'>[words]</td>"
|
||||
HTML += "<td colspan='3' align='center'>[jointext(words, null)]</td>"
|
||||
HTML += "</tr>"
|
||||
|
||||
HTML += "</table>"
|
||||
@@ -221,56 +190,50 @@
|
||||
HTML += "<br><font color='0000FF'>[extended_desc]</font>"
|
||||
|
||||
HTML += "</body></html>"
|
||||
user << browse(HTML, "window=circuit-\ref[src];size=600x350;border=1;can_resize=1;can_close=1;can_minimize=1")
|
||||
user << browse(jointext(HTML, null), "window=circuit-\ref[src];size=600x350;border=1;can_resize=1;can_close=1;can_minimize=1")
|
||||
|
||||
//user << sanitize(HTML, "window=debug;size=400x400;border=1;can_resize=1;can_close=1;can_minimize=1")
|
||||
//world << sanitize(HTML)
|
||||
|
||||
user.set_machine(src)
|
||||
onclose(user, "circuit-\ref[src]")
|
||||
|
||||
/obj/item/integrated_circuit/Topic(href, href_list[])
|
||||
var/mob/living/user = locate(href_list["user"]) in mob_list
|
||||
/obj/item/integrated_circuit/Topic(href, href_list, state = physical_state)
|
||||
if(..())
|
||||
return 1
|
||||
var/pin = locate(href_list["pin"]) in inputs + outputs + activators
|
||||
|
||||
if(!user || !user.Adjacent(get_turf(src)) )
|
||||
return 1
|
||||
|
||||
if(!user.canmove || user.stat || user.restrained())
|
||||
return
|
||||
|
||||
var/obj/held_item = usr.get_active_hand()
|
||||
if(href_list["wire"])
|
||||
if(ishuman(user) && Adjacent(user))
|
||||
var/mob/living/carbon/human/H = user
|
||||
var/obj/held_item = H.get_active_hand()
|
||||
|
||||
if(istype(held_item, /obj/item/device/integrated_electronics/wirer))
|
||||
var/obj/item/device/integrated_electronics/wirer/wirer = held_item
|
||||
if(pin)
|
||||
wirer.wire(pin, user)
|
||||
wirer.wire(pin, usr)
|
||||
|
||||
else if(istype(held_item, /obj/item/device/integrated_electronics/debugger))
|
||||
var/obj/item/device/integrated_electronics/debugger/debugger = held_item
|
||||
if(pin)
|
||||
debugger.write_data(pin, user)
|
||||
|
||||
// if(istype(H.r_hand, /obj/item/device/integrated_electronics/wirer))
|
||||
// wirer = H.r_hand
|
||||
// else if(istype(H.l_hand, /obj/item/device/integrated_electronics/wirer))
|
||||
// wirer = H.l_hand
|
||||
|
||||
// if(wirer && pin)
|
||||
// wirer.wire(pin, user)
|
||||
debugger.write_data(pin, usr)
|
||||
else
|
||||
user << "<span class='warning'>You can't do a whole lot without tools.</span>"
|
||||
to_chat(usr, "<span class='warning'>You can't do a whole lot without the proper tools.</span>")
|
||||
|
||||
if(href_list["examine"])
|
||||
examine(user)
|
||||
examine(usr)
|
||||
|
||||
if(href_list["rename"])
|
||||
rename_component(user)
|
||||
rename_component(usr)
|
||||
|
||||
interact(user) // To refresh the UI.
|
||||
if(href_list["remove"])
|
||||
if(istype(held_item, /obj/item/weapon/screwdriver))
|
||||
disconnect_all()
|
||||
var/turf/T = get_turf(src)
|
||||
forceMove(T)
|
||||
playsound(T, 'sound/items/Crowbar.ogg', 50, 1)
|
||||
to_chat(usr, "<span class='notice'>You pop \the [src] out of the case, and slide it out.</span>")
|
||||
else
|
||||
to_chat(usr, "<span class='warning'>You need a screwdriver to remove components.</span>")
|
||||
var/obj/item/device/electronic_assembly/ea = loc
|
||||
if(istype(ea))
|
||||
ea.interact(usr)
|
||||
return
|
||||
|
||||
interact(usr) // To refresh the UI.
|
||||
|
||||
/datum/integrated_io
|
||||
var/name = "input/output"
|
||||
@@ -287,8 +250,20 @@
|
||||
|
||||
/datum/integrated_io/Destroy()
|
||||
disconnect()
|
||||
data = null
|
||||
holder = null
|
||||
..()
|
||||
. = ..()
|
||||
|
||||
/datum/integrated_io/nano_host()
|
||||
return holder
|
||||
|
||||
|
||||
/datum/integrated_io/proc/data_as_type(var/as_type)
|
||||
if(!isweakref(data))
|
||||
return
|
||||
var/weakref/w = data
|
||||
var/output = w.resolve()
|
||||
return istype(output, as_type) ? output : null
|
||||
|
||||
/datum/integrated_io/proc/display_data()
|
||||
if(isnull(data))
|
||||
@@ -316,33 +291,28 @@
|
||||
push_data()
|
||||
|
||||
/datum/integrated_io/proc/write_data_to_pin(var/new_data)
|
||||
if(isnull(new_data) || isnum(new_data) || istext(new_data) || istype(new_data, /atom/) ) // Anything else is a type we don't want.
|
||||
if(isnull(new_data) || isnum(new_data) || istext(new_data) || isweakref(new_data)) // Anything else is a type we don't want.
|
||||
data = new_data
|
||||
holder.on_data_written()
|
||||
|
||||
/datum/integrated_io/proc/push_data()
|
||||
if(linked.len)
|
||||
for(var/datum/integrated_io/io in linked)
|
||||
io.write_data_to_pin(data)
|
||||
|
||||
/datum/integrated_io/activate/push_data()
|
||||
if(linked.len)
|
||||
for(var/datum/integrated_io/io in linked)
|
||||
io.holder.work()
|
||||
io.holder.check_then_do_work()
|
||||
|
||||
/datum/integrated_io/proc/pull_data()
|
||||
if(linked.len)
|
||||
for(var/datum/integrated_io/io in linked)
|
||||
write_data_to_pin(io.data)
|
||||
|
||||
/datum/integrated_io/proc/get_linked_to_desc()
|
||||
if(linked.len)
|
||||
var/result = english_list(linked)
|
||||
return "the [result]"
|
||||
return "the [english_list(linked)]"
|
||||
return "nothing"
|
||||
|
||||
/datum/integrated_io/proc/disconnect()
|
||||
if(linked.len)
|
||||
//First we iterate over everything we are linked to.
|
||||
for(var/datum/integrated_io/their_io in linked)
|
||||
//While doing that, we iterate them as well, and disconnect ourselves from them.
|
||||
@@ -372,11 +342,14 @@
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.push_data()
|
||||
|
||||
/obj/item/integrated_circuit/proc/work(var/datum/integrated_io/io)
|
||||
if(last_used + cooldown_per_use > world.time) // All intergrated circuits have an internal cooldown, to protect from spam.
|
||||
return 0
|
||||
last_used = world.time
|
||||
return 1
|
||||
/obj/item/integrated_circuit/proc/check_then_do_work()
|
||||
if(world.time < next_use) // All intergrated circuits have an internal cooldown, to protect from spam.
|
||||
return
|
||||
next_use = world.time + cooldown_per_use
|
||||
do_work()
|
||||
|
||||
/obj/item/integrated_circuit/proc/do_work()
|
||||
return
|
||||
|
||||
/obj/item/integrated_circuit/proc/disconnect_all()
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
|
||||
@@ -1,25 +1,10 @@
|
||||
//These circuits do simple math.
|
||||
/obj/item/integrated_circuit/arithmetic
|
||||
complexity = 1
|
||||
number_of_inputs = 8
|
||||
number_of_outputs = 1
|
||||
number_of_activators = 1
|
||||
input_names = list(
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
"D",
|
||||
"E",
|
||||
"F",
|
||||
"G",
|
||||
"H"
|
||||
)
|
||||
output_names = list(
|
||||
"result"
|
||||
)
|
||||
activator_names = list(
|
||||
"compute"
|
||||
)
|
||||
inputs = list("A","B","C","D","E","F","G","H")
|
||||
outputs = list("result")
|
||||
activators = list("compute")
|
||||
category = /obj/item/integrated_circuit/arithmetic
|
||||
|
||||
// +Adding+ //
|
||||
|
||||
@@ -28,8 +13,7 @@
|
||||
desc = "This circuit can add numbers together."
|
||||
icon_state = "addition"
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/addition/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/arithmetic/addition/do_work()
|
||||
var/result = 0
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.pull_data()
|
||||
@@ -47,7 +31,7 @@
|
||||
desc = "This circuit can subtract numbers."
|
||||
icon_state = "subtraction"
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/subtraction/work()
|
||||
/obj/item/integrated_circuit/arithmetic/subtraction/do_work()
|
||||
if(..())
|
||||
var/result = 0
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
@@ -66,8 +50,7 @@
|
||||
desc = "This circuit can multiply numbers."
|
||||
icon_state = "multiplication"
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/subtraction/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/arithmetic/subtraction/do_work()
|
||||
var/result = 0
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.pull_data()
|
||||
@@ -85,8 +68,7 @@
|
||||
desc = "This circuit can divide numbers, just don't think about trying to divide by zero!"
|
||||
icon_state = "division"
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/division/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/arithmetic/division/do_work()
|
||||
var/result = 0
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.pull_data()
|
||||
@@ -103,11 +85,9 @@
|
||||
name = "absolute circuit"
|
||||
desc = "This outputs a non-negative version of the number you put in. This may also be thought of as its distance from zero."
|
||||
icon_state = "absolute"
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 1
|
||||
inputs = list("A")
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/absolute/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/arithmetic/absolute/do_work()
|
||||
var/result = 0
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.pull_data()
|
||||
@@ -125,8 +105,7 @@
|
||||
desc = "This circuit is of average quality, however it will compute the average for numbers you give it."
|
||||
icon_state = "average"
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/average/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/arithmetic/average/do_work()
|
||||
var/result = 0
|
||||
var/inputs_used = 0
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
@@ -147,11 +126,9 @@
|
||||
name = "pi constant circuit"
|
||||
desc = "Not recommended for cooking. Outputs '3.14159' when it receives a pulse."
|
||||
icon_state = "pi"
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 1
|
||||
inputs = list()
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/pi/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/arithmetic/pi/do_work()
|
||||
var/datum/integrated_io/output/O = outputs[1]
|
||||
O.data = 3.14159
|
||||
O.push_data()
|
||||
@@ -161,16 +138,9 @@
|
||||
name = "random number generator circuit"
|
||||
desc = "This gives a random (integer) number between values A and B inclusive."
|
||||
icon_state = "random"
|
||||
number_of_inputs = 2
|
||||
number_of_outputs = 1
|
||||
number_of_activators = 1
|
||||
input_names = list(
|
||||
"L",
|
||||
"H"
|
||||
)
|
||||
inputs = list("L","H")
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/random/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/arithmetic/random/do_work()
|
||||
var/result = 0
|
||||
var/datum/integrated_io/L = inputs[1]
|
||||
var/datum/integrated_io/H = inputs[2]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/obj/item/device/electronic_assembly
|
||||
name = "electronic assembly"
|
||||
desc = "It's a case, for building electronics with."
|
||||
w_class = ITEMSIZE_SMALL
|
||||
w_class = 2
|
||||
icon = 'icons/obj/electronic_assemblies.dmi'
|
||||
icon_state = "setup_small"
|
||||
var/max_components = 10
|
||||
@@ -11,62 +11,59 @@
|
||||
/obj/item/device/electronic_assembly/medium
|
||||
name = "electronic mechanism"
|
||||
icon_state = "setup_medium"
|
||||
w_class = ITEMSIZE_NORMAL
|
||||
w_class = 3
|
||||
max_components = 20
|
||||
max_complexity = 80
|
||||
|
||||
/obj/item/device/electronic_assembly/large
|
||||
name = "electronic machine"
|
||||
icon_state = "setup_large"
|
||||
w_class = ITEMSIZE_LARGE
|
||||
w_class = 4
|
||||
max_components = 30
|
||||
max_complexity = 120
|
||||
|
||||
/obj/item/device/electronic_assembly/drone
|
||||
name = "electronic drone"
|
||||
icon_state = "setup_drone"
|
||||
w_class = ITEMSIZE_NORMAL
|
||||
w_class = 3
|
||||
max_components = 25
|
||||
max_complexity = 100
|
||||
|
||||
/obj/item/device/electronic_assembly/interact(mob/user)
|
||||
if(get_dist(get_turf(src), user) > 1)
|
||||
user.unset_machine(src)
|
||||
if(!CanInteract(user, physical_state))
|
||||
return
|
||||
|
||||
var/total_parts = 0
|
||||
var/total_complexity = 0
|
||||
for(var/obj/item/integrated_circuit/part in contents)
|
||||
total_parts++
|
||||
total_complexity = total_complexity + part.complexity
|
||||
var/HTML = "<html><head><title>[src.name]</title></head><body>"
|
||||
var/HTML = list()
|
||||
|
||||
HTML += "<br><a href='?src=\ref[src];user=\ref[user]'>\[Refresh\]</a> | "
|
||||
HTML += "<a href='?src=\ref[src];user=\ref[user];rename=1'>\[Rename\]</a><br>"
|
||||
HTML += "<html><head><title>[src.name]</title></head><body>"
|
||||
HTML += "<br><a href='?src=\ref[src]'>\[Refresh\]</a> | "
|
||||
HTML += "<a href='?src=\ref[src];rename=1'>\[Rename\]</a><br>"
|
||||
HTML += "[total_parts]/[max_components] ([round((total_parts / max_components) * 100, 0.1)]%) space taken up in the assembly.<br>"
|
||||
HTML += "[total_complexity]/[max_complexity] ([round((total_complexity / max_complexity) * 100, 0.1)]%) maximum complexity."
|
||||
HTML += "<br><br>"
|
||||
HTML += "Components;<br>"
|
||||
for(var/obj/item/integrated_circuit/circuit in contents)
|
||||
HTML += "<a href=?src=\ref[circuit];examine=1;user=\ref[user]>[circuit.name]</a> | "
|
||||
HTML += "<a href=?src=\ref[circuit];rename=1;user=\ref[user]>\[Rename\]</a>"
|
||||
HTML += "<a href=?src=\ref[circuit];examine=1>[circuit.name]</a> | "
|
||||
HTML += "<a href=?src=\ref[circuit];rename=1>\[Rename\]</a> | "
|
||||
HTML += "<a href=?src=\ref[circuit];remove=1>\[Remove\]</a>"
|
||||
HTML += "<br>"
|
||||
|
||||
HTML += "</body></html>"
|
||||
user << browse(HTML, "window=assembly-\ref[src];size=600x350;border=1;can_resize=1;can_close=1;can_minimize=1")
|
||||
user << browse(jointext(HTML,null), "window=assembly-\ref[src];size=600x350;border=1;can_resize=1;can_close=1;can_minimize=1")
|
||||
|
||||
/obj/item/device/electronic_assembly/Topic(href, href_list[])
|
||||
var/mob/living/user = locate(href_list["user"]) in mob_list
|
||||
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
if(!user.canmove || user.stat || user.restrained())
|
||||
return
|
||||
|
||||
if(href_list["rename"])
|
||||
rename(user)
|
||||
rename(usr)
|
||||
|
||||
interact(user) // To refresh the UI.
|
||||
interact(usr) // To refresh the UI.
|
||||
|
||||
/obj/item/device/electronic_assembly/verb/rename()
|
||||
set name = "Rename Circuit"
|
||||
@@ -74,14 +71,12 @@
|
||||
set desc = "Rename your circuit, useful to stay organized."
|
||||
|
||||
var/mob/M = usr
|
||||
|
||||
if(!M.canmove || M.stat || M.restrained())
|
||||
if(!CanInteract(M, physical_state))
|
||||
return
|
||||
|
||||
var/input = sanitizeSafe(input("What do you want to name this?", "Rename", src.name), MAX_NAME_LEN)
|
||||
|
||||
if(src && input)
|
||||
M << "<span class='notice'>The machine now has a label reading '[input]'.</span>"
|
||||
var/input = sanitizeSafe(input("What do you want to name this?", "Rename", src.name) as null|text, MAX_NAME_LEN)
|
||||
if(src && input && CanInteract(M, physical_state))
|
||||
to_chat(M, "<span class='notice'>The machine now has a label reading '[input]'.</span>")
|
||||
name = input
|
||||
|
||||
/obj/item/device/electronic_assembly/update_icon()
|
||||
@@ -91,22 +86,18 @@
|
||||
icon_state = initial(icon_state)
|
||||
|
||||
/obj/item/device/electronic_assembly/examine(mob/user)
|
||||
..()
|
||||
if(user.Adjacent(src))
|
||||
if(!opened)
|
||||
. = ..(user, 1)
|
||||
if(.)
|
||||
for(var/obj/item/integrated_circuit/output/screen/S in contents)
|
||||
if(S.stuff_to_display)
|
||||
user << "There's a little screen labeled '[S.name]', which displays '[S.stuff_to_display]'."
|
||||
else
|
||||
to_chat(user, "There's a little screen labeled '[S.name]', which displays '[S.stuff_to_display]'.")
|
||||
if(opened)
|
||||
interact(user)
|
||||
// var/obj/item/integrated_circuit/IC = input(user, "Which circuit do you want to examine?", "Examination") as null|anything in contents
|
||||
// if(IC)
|
||||
// IC.examine(user)
|
||||
|
||||
/obj/item/device/electronic_assembly/attackby(var/obj/item/I, var/mob/user)
|
||||
if(istype(I, /obj/item/integrated_circuit))
|
||||
if(!opened)
|
||||
user << "<span class='warning'>\The [src] isn't opened, so you can't put anything inside. Try using a crowbar.</span>"
|
||||
to_chat(user, "<span class='warning'>\The [src] isn't opened, so you can't put anything inside. Try using a crowbar.</span>")
|
||||
return 0
|
||||
var/obj/item/integrated_circuit/IC = I
|
||||
var/total_parts = 0
|
||||
@@ -115,51 +106,42 @@
|
||||
total_parts++
|
||||
total_complexity = total_complexity + part.complexity
|
||||
|
||||
if( (total_parts + 1) >= max_components)
|
||||
user << "<span class='warning'>You can't seem to add this [IC.name], since there's no more room.</span>"
|
||||
if( (total_parts + 1) > max_components)
|
||||
to_chat(user, "<span class='warning'>You can't seem to add this [IC.name], since there's no more room.</span>")
|
||||
return 0
|
||||
if( (total_complexity + IC.complexity) >= max_complexity)
|
||||
user << "<span class='warning'>You can't seem to add this [IC.name], since this setup's too complicated for the case.</span>"
|
||||
if( (total_complexity + IC.complexity) > max_complexity)
|
||||
to_chat(user, "<span class='warning'>You can't seem to add this [IC.name], since this setup's too complicated for the case.</span>")
|
||||
return 0
|
||||
|
||||
user << "<span class='notice'>You slide \the [IC] inside \the [src].</span>"
|
||||
to_chat(user, "<span class='notice'>You slide \the [IC] inside \the [src].</span>")
|
||||
user.drop_item()
|
||||
IC.forceMove(src)
|
||||
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
|
||||
if(istype(I, /obj/item/weapon/screwdriver))
|
||||
if(!opened)
|
||||
user << "<span class='warning'>\The [src] isn't opened, so you can't remove anything inside. Try using a crowbar.</span>"
|
||||
return 0
|
||||
if(!contents.len)
|
||||
user << "<span class='warning'>There's nothing inside this to remove!</span>"
|
||||
return 0
|
||||
var/obj/item/integrated_circuit/option = input("What do you want to remove?", "Component Removal") as null|anything in contents
|
||||
if(option)
|
||||
option.disconnect_all()
|
||||
option.forceMove(get_turf(src))
|
||||
playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1)
|
||||
user << "<span class='notice'>You pop \the [option] out of the case, and slide it out.</span>"
|
||||
if(istype(I, /obj/item/weapon/crowbar))
|
||||
playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1)
|
||||
playsound(get_turf(src), 'sound/items/Deconstruct.ogg', 50, 1)
|
||||
interact(user)
|
||||
else if(istype(I, /obj/item/weapon/crowbar))
|
||||
playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1)
|
||||
opened = !opened
|
||||
user << "<span class='notice'>You [opened ? "opened" : "closed"] \the [src].</span>"
|
||||
to_chat(user, "<span class='notice'>You [opened ? "opened" : "closed"] \the [src].</span>")
|
||||
update_icon()
|
||||
if(istype(I, /obj/item/device/integrated_electronics/wirer))
|
||||
else if(istype(I, /obj/item/device/integrated_electronics/wirer) || istype(I, /obj/item/device/integrated_electronics/debugger) || istype(I, /obj/item/weapon/screwdriver))
|
||||
if(opened)
|
||||
var/obj/item/integrated_circuit/IC = input(user, "Which circuit do you want to examine?", "Examination") as null|anything in contents
|
||||
if(IC)
|
||||
IC.examine(user)
|
||||
interact(user)
|
||||
else
|
||||
user << "<span class='warning'>\The [src] isn't opened, so you can't fiddle with the internal components. \
|
||||
Try using a crowbar.</span>"
|
||||
to_chat(user, "<span class='warning'>\The [src] isn't opened, so you can't fiddle with the internal components. \
|
||||
Try using a crowbar.</span>")
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/item/device/electronic_assembly/attack_self(mob/user)
|
||||
if(opened)
|
||||
interact(user)
|
||||
|
||||
var/list/available_inputs = list()
|
||||
for(var/obj/item/integrated_circuit/input/input in contents)
|
||||
if(input.can_be_asked_input)
|
||||
available_inputs.Add(input)
|
||||
var/obj/item/integrated_circuit/input/choice = input(user, "What do you want to interact with?", "Interaction") as null|anything in available_inputs
|
||||
if(choice)
|
||||
if(choice && CanInteract(user, physical_state))
|
||||
choice.ask_for_input(user)
|
||||
|
||||
/obj/item/device/electronic_assembly/emp_act(severity)
|
||||
|
||||
@@ -1,26 +1,17 @@
|
||||
//These circuits convert one variable to another.
|
||||
/obj/item/integrated_circuit/converter
|
||||
complexity = 2
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 1
|
||||
number_of_activators = 1
|
||||
input_names = list(
|
||||
"input",
|
||||
)
|
||||
output_names = list(
|
||||
"result"
|
||||
)
|
||||
activator_names = list(
|
||||
"convert"
|
||||
)
|
||||
inputs = list("input")
|
||||
outputs = list("output")
|
||||
activators = list("convert")
|
||||
category = /obj/item/integrated_circuit/converter
|
||||
|
||||
/obj/item/integrated_circuit/converter/num2text
|
||||
name = "number to string"
|
||||
desc = "This circuit can convert a number variable into a string."
|
||||
icon_state = "num-string"
|
||||
|
||||
/obj/item/integrated_circuit/converter/num2text/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/converter/num2text/do_work()
|
||||
var/result = null
|
||||
var/datum/integrated_io/incoming = inputs[1]
|
||||
var/datum/integrated_io/outgoing = outputs[1]
|
||||
@@ -35,8 +26,7 @@
|
||||
desc = "This circuit can convert a string variable into a number."
|
||||
icon_state = "string-num"
|
||||
|
||||
/obj/item/integrated_circuit/converter/text2num/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/converter/text2num/do_work()
|
||||
var/result = null
|
||||
var/datum/integrated_io/incoming = inputs[1]
|
||||
var/datum/integrated_io/outgoing = outputs[1]
|
||||
@@ -51,14 +41,12 @@
|
||||
desc = "This circuit can convert a reference to something else to a string, specifically the name of that reference."
|
||||
icon_state = "ref-string"
|
||||
|
||||
/obj/item/integrated_circuit/converter/ref2text/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/converter/ref2text/do_work()
|
||||
var/result = null
|
||||
var/datum/integrated_io/incoming = inputs[1]
|
||||
var/datum/integrated_io/outgoing = outputs[1]
|
||||
if(incoming.data && istype(incoming.data, /atom/))
|
||||
var/atom/A = incoming.data
|
||||
result = A.name
|
||||
var/atom/A = incoming.data_as_type(/atom)
|
||||
result = A && A.name
|
||||
|
||||
outgoing.data = result
|
||||
outgoing.push_data()
|
||||
@@ -68,8 +56,7 @@
|
||||
desc = "this will cause a string to come out in all lowercase."
|
||||
icon_state = "lowercase"
|
||||
|
||||
/obj/item/integrated_circuit/converter/lowercase/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/converter/lowercase/do_work()
|
||||
var/result = null
|
||||
var/datum/integrated_io/incoming = inputs[1]
|
||||
var/datum/integrated_io/outgoing = outputs[1]
|
||||
@@ -84,8 +71,7 @@
|
||||
desc = "THIS WILL CAUSE A STRING TO COME OUT IN ALL UPPERCASE."
|
||||
icon_state = "uppercase"
|
||||
|
||||
/obj/item/integrated_circuit/converter/uppercase/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/converter/uppercase/do_work()
|
||||
var/result = null
|
||||
var/datum/integrated_io/incoming = inputs[1]
|
||||
var/datum/integrated_io/outgoing = outputs[1]
|
||||
@@ -99,29 +85,11 @@
|
||||
name = "concatenatior"
|
||||
desc = "This joins many strings together to get one big string."
|
||||
complexity = 4
|
||||
number_of_inputs = 8
|
||||
number_of_outputs = 1
|
||||
number_of_activators = 1
|
||||
input_names = list(
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
"D",
|
||||
"E",
|
||||
"F",
|
||||
"G",
|
||||
"H"
|
||||
)
|
||||
output_names = list(
|
||||
"result"
|
||||
)
|
||||
activator_names = list(
|
||||
"concatenate"
|
||||
)
|
||||
inputs = list("A","B","C","D","E","F","G","H")
|
||||
outputs = list("result")
|
||||
activators = list("concatenate")
|
||||
|
||||
|
||||
/obj/item/integrated_circuit/converter/concatenatior/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/converter/concatenatior/do_work()
|
||||
var/result = null
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.pull_data()
|
||||
|
||||
@@ -4,21 +4,11 @@
|
||||
desc = "This allows you to easily know the position of a machine containing this device."
|
||||
icon_state = "gps"
|
||||
complexity = 4
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 2
|
||||
number_of_activators = 1
|
||||
input_names = list(
|
||||
)
|
||||
output_names = list(
|
||||
"X (abs)",
|
||||
"Y (abs)"
|
||||
)
|
||||
activator_names = list(
|
||||
"get coordinates"
|
||||
)
|
||||
inputs = list()
|
||||
outputs = list("X (abs)", "Y (abs)")
|
||||
activators = list("get coordinates")
|
||||
|
||||
/obj/item/integrated_circuit/gps/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/gps/do_work()
|
||||
var/turf/T = get_turf(src)
|
||||
var/datum/integrated_io/result_x = outputs[1]
|
||||
var/datum/integrated_io/result_y = outputs[2]
|
||||
@@ -38,24 +28,11 @@
|
||||
name = "abs to rel coordinate converter"
|
||||
desc = "Easily convert absolute coordinates to relative coordinates with this."
|
||||
complexity = 4
|
||||
number_of_inputs = 4
|
||||
number_of_outputs = 2
|
||||
number_of_activators = 1
|
||||
input_names = list(
|
||||
"X1 (abs)",
|
||||
"Y1 (abs)",
|
||||
"X2 (abs)",
|
||||
"Y2 (abs)"
|
||||
)
|
||||
output_names = list(
|
||||
"X (rel)",
|
||||
"Y (rel)"
|
||||
)
|
||||
activator_names = list(
|
||||
"compute rel coordinates"
|
||||
)
|
||||
inputs = list("X1 (abs)", "Y1 (abs)", "X2 (abs)", "Y2 (abs)")
|
||||
outputs = list("X (rel)", "Y (rel)")
|
||||
activators = list("compute rel coordinates")
|
||||
|
||||
/obj/item/integrated_circuit/abs_to_rel_coords/work()
|
||||
/obj/item/integrated_circuit/abs_to_rel_coords/do_work()
|
||||
var/datum/integrated_io/x1 = inputs[1]
|
||||
var/datum/integrated_io/y1 = inputs[2]
|
||||
|
||||
@@ -69,7 +46,5 @@
|
||||
result_x.data = x1.data - x2.data
|
||||
result_y.data = y1.data - y2.data
|
||||
|
||||
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
O.push_data()
|
||||
..()
|
||||
|
||||
@@ -3,38 +3,22 @@
|
||||
desc = "Splits incoming data into all of the output pins."
|
||||
icon_state = "splitter"
|
||||
complexity = 3
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 2
|
||||
input_names = list(
|
||||
"data to split"
|
||||
)
|
||||
output_names = list(
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
"D",
|
||||
"E",
|
||||
"F",
|
||||
"G",
|
||||
"H"
|
||||
)
|
||||
inputs = list("data to split")
|
||||
outputs = list("A","B")
|
||||
|
||||
/obj/item/integrated_circuit/transfer/splitter/medium
|
||||
name = "four splitter"
|
||||
icon_state = "splitter4"
|
||||
complexity = 5
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 4
|
||||
outputs = list("A","B","C","D")
|
||||
|
||||
/obj/item/integrated_circuit/transfer/splitter/large
|
||||
name = "eight splitter"
|
||||
icon_state = "splitter8"
|
||||
complexity = 9
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 8
|
||||
outputs = list("A","B","C","D","E","F","G","H")
|
||||
|
||||
/obj/item/integrated_circuit/transfer/splitter/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/transfer/splitter/do_work()
|
||||
var/datum/integrated_io/I = inputs[1]
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
O.data = I.data
|
||||
@@ -44,8 +28,37 @@
|
||||
desc = "Splits incoming activation pulses into all of the output pins."
|
||||
icon_state = "splitter"
|
||||
complexity = 3
|
||||
number_of_activators = 3
|
||||
activator_names = list(
|
||||
activators = list(
|
||||
"incoming pulse",
|
||||
"outgoing pulse A",
|
||||
"outgoing pulse B"
|
||||
)
|
||||
|
||||
/obj/item/integrated_circuit/transfer/activator_splitter/do_work()
|
||||
for(var/datum/integrated_io/activate/A in outputs)
|
||||
if(A == activators[1])
|
||||
continue
|
||||
if(A.linked.len)
|
||||
for(var/datum/integrated_io/activate/target in A.linked)
|
||||
target.holder.check_then_do_work()
|
||||
|
||||
/obj/item/integrated_circuit/transfer/activator_splitter/medium
|
||||
name = "four activator splitter"
|
||||
icon_state = "splitter4"
|
||||
complexity = 5
|
||||
activators = list(
|
||||
"incoming pulse",
|
||||
"outgoing pulse A",
|
||||
"outgoing pulse B",
|
||||
"outgoing pulse C",
|
||||
"outgoing pulse D"
|
||||
)
|
||||
|
||||
/obj/item/integrated_circuit/transfer/activator_splitter/large
|
||||
name = "eight activator splitter"
|
||||
icon_state = "splitter4"
|
||||
complexity = 9
|
||||
activators = list(
|
||||
"incoming pulse",
|
||||
"outgoing pulse A",
|
||||
"outgoing pulse B",
|
||||
@@ -56,24 +69,3 @@
|
||||
"outgoing pulse G",
|
||||
"outgoing pulse H"
|
||||
)
|
||||
|
||||
/obj/item/integrated_circuit/transfer/activator_splitter/work()
|
||||
if(..())
|
||||
for(var/datum/integrated_io/activate/A in outputs)
|
||||
if(A == activators[1])
|
||||
continue
|
||||
if(A.linked.len)
|
||||
for(var/datum/integrated_io/activate/target in A.linked)
|
||||
target.holder.work()
|
||||
|
||||
/obj/item/integrated_circuit/transfer/activator_splitter/medium
|
||||
name = "four activator splitter"
|
||||
icon_state = "splitter4"
|
||||
complexity = 5
|
||||
number_of_activators = 5
|
||||
|
||||
/obj/item/integrated_circuit/transfer/activator_splitter/large
|
||||
name = "eight activator splitter"
|
||||
icon_state = "splitter4"
|
||||
complexity = 9
|
||||
number_of_activators = 9
|
||||
|
||||
@@ -8,41 +8,32 @@
|
||||
name = "button"
|
||||
desc = "This tiny button must do something, right?"
|
||||
icon_state = "button"
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 0
|
||||
number_of_activators = 1
|
||||
complexity = 1
|
||||
can_be_asked_input = 1
|
||||
activator_names = list(
|
||||
"on pressed"
|
||||
)
|
||||
inputs = list()
|
||||
outputs = list()
|
||||
activators = list("on pressed")
|
||||
|
||||
/obj/item/integrated_circuit/input/button/ask_for_input(mob/user) //Bit misleading name for this specific use.
|
||||
var/datum/integrated_io/A = activators[1]
|
||||
if(A.linked.len)
|
||||
for(var/datum/integrated_io/activate/target in A.linked)
|
||||
target.holder.work()
|
||||
user << "<span class='notice'>You press the button labeled '[src.name]'.</span>"
|
||||
target.holder.check_then_do_work()
|
||||
to_chat(user, "<span class='notice'>You press the button labeled '[src.name]'.</span>")
|
||||
|
||||
/obj/item/integrated_circuit/input/numberpad
|
||||
name = "number pad"
|
||||
desc = "This small number pad allows someone to input a number into the system."
|
||||
icon_state = "numberpad"
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 1
|
||||
number_of_activators = 1
|
||||
complexity = 2
|
||||
can_be_asked_input = 1
|
||||
output_names = list(
|
||||
"number entered"
|
||||
)
|
||||
activator_names = list(
|
||||
"on entered"
|
||||
)
|
||||
inputs = list()
|
||||
outputs = list("number entered")
|
||||
activators = list("on entered")
|
||||
|
||||
/obj/item/integrated_circuit/input/numberpad/ask_for_input(mob/user)
|
||||
var/new_input = input(user, "Enter a number, please.","Number pad") as null|num
|
||||
if(isnum(new_input))
|
||||
if(isnum(new_input) && CanInteract(user, physical_state))
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
O.data = new_input
|
||||
O.push_data()
|
||||
@@ -53,21 +44,15 @@
|
||||
name = "text pad"
|
||||
desc = "This small text pad allows someone to input a string into the system."
|
||||
icon_state = "textpad"
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 1
|
||||
number_of_activators = 1
|
||||
complexity = 2
|
||||
can_be_asked_input = 1
|
||||
output_names = list(
|
||||
"string entered"
|
||||
)
|
||||
activator_names = list(
|
||||
"on entered"
|
||||
)
|
||||
inputs = list()
|
||||
outputs = list("string entered")
|
||||
activators = list("on entered")
|
||||
|
||||
/obj/item/integrated_circuit/input/textpad/ask_for_input(mob/user)
|
||||
var/new_input = input(user, "Enter some words, please.","Number pad") as null|text
|
||||
if(new_input && istext(new_input))
|
||||
if(istext(new_input) && CanInteract(user, physical_state))
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
O.data = new_input
|
||||
O.push_data()
|
||||
@@ -78,27 +63,16 @@
|
||||
name = "integrated medical analyser"
|
||||
desc = "A very small version of the common medical analyser. This allows the machine to know how healthy someone is."
|
||||
icon_state = "medscan"
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 2
|
||||
number_of_activators = 1
|
||||
complexity = 4
|
||||
input_names = list(
|
||||
"target ref"
|
||||
)
|
||||
output_names = list(
|
||||
"total health %",
|
||||
"total missing health"
|
||||
)
|
||||
activator_names = list(
|
||||
"scan"
|
||||
)
|
||||
inputs = list("target ref")
|
||||
outputs = list("total health %", "total missing health")
|
||||
activators = list("scan")
|
||||
|
||||
/obj/item/integrated_circuit/input/med_scanner/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/input/med_scanner/do_work()
|
||||
var/datum/integrated_io/I = inputs[1]
|
||||
if(!I.data || !ishuman(I.data)) //Invalid input
|
||||
var/mob/living/carbon/human/H = I.data_as_type(/mob/living/carbon/human)
|
||||
if(!istype(H)) //Invalid input
|
||||
return
|
||||
var/mob/living/carbon/human/H = I.data
|
||||
if(H.Adjacent(get_turf(src))) // Like normal analysers, it can't be used at range.
|
||||
var/total_health = round(H.health/H.maxHealth, 0.1)*100
|
||||
var/missing_health = H.maxHealth - H.health
|
||||
@@ -117,14 +91,9 @@
|
||||
desc = "A very small version of the common medical analyser. This allows the machine to know how healthy someone is. \
|
||||
This type is much more precise, allowing the machine to know much more about the target than a normal analyzer."
|
||||
icon_state = "medscan_adv"
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 7
|
||||
number_of_activators = 1
|
||||
complexity = 12
|
||||
input_names = list(
|
||||
"target ref"
|
||||
)
|
||||
output_names = list(
|
||||
inputs = list("target ref")
|
||||
outputs = list(
|
||||
"total health %",
|
||||
"total missing health",
|
||||
"brute damage",
|
||||
@@ -133,16 +102,13 @@
|
||||
"oxy damage",
|
||||
"clone damage"
|
||||
)
|
||||
activator_names = list(
|
||||
"scan"
|
||||
)
|
||||
activators = list("scan")
|
||||
|
||||
/obj/item/integrated_circuit/input/adv_med_scanner/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/input/adv_med_scanner/do_work()
|
||||
var/datum/integrated_io/I = inputs[1]
|
||||
if(!I.data || !ishuman(I.data)) //Invalid input
|
||||
var/mob/living/carbon/human/H = I.data_as_type(/mob/living/carbon/human)
|
||||
if(!istype(H)) //Invalid input
|
||||
return
|
||||
var/mob/living/carbon/human/H = I.data
|
||||
if(H.Adjacent(get_turf(src))) // Like normal analysers, it can't be used at range.
|
||||
var/total_health = round(H.health/H.maxHealth, 0.1)*100
|
||||
var/missing_health = H.maxHealth - H.health
|
||||
@@ -170,29 +136,17 @@
|
||||
name = "local locator"
|
||||
desc = "This is needed for certain devices that demand a reference for a target to act upon. This type only locates something \
|
||||
that is holding the machine containing it."
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 1
|
||||
number_of_activators = 1
|
||||
complexity = 4
|
||||
output_names = list(
|
||||
"located ref"
|
||||
)
|
||||
activator_names = list(
|
||||
"locate"
|
||||
)
|
||||
inputs = list()
|
||||
outputs = list("located ref")
|
||||
activators = list("locate")
|
||||
|
||||
/obj/item/integrated_circuit/input/local_locator/work()
|
||||
if(..())
|
||||
var/mob/living/L = null
|
||||
/obj/item/integrated_circuit/input/local_locator/do_work()
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
O.data = null
|
||||
if(istype(src.loc, /obj/item/device/electronic_assembly)) // Check to make sure we're actually in a machine.
|
||||
var/obj/item/device/electronic_assembly/assembly = src.loc
|
||||
if(istype(assembly.loc, /mob/living)) // Now check if someone's holding us.
|
||||
L = assembly.loc
|
||||
|
||||
if(L)
|
||||
O.data = L
|
||||
O.data = weakref(assembly.loc)
|
||||
|
||||
O.push_data()
|
||||
|
||||
@@ -203,25 +157,17 @@
|
||||
The two input pins are to configure the integrated signaler's settings. Note that the frequency should not have a decimal in it. \
|
||||
Meaning the default frequency is expressed as 1457, not 145.7. To send a signal, pulse the 'send signal' activator pin."
|
||||
icon_state = "signal"
|
||||
number_of_inputs = 2
|
||||
number_of_outputs = 0
|
||||
number_of_activators = 2
|
||||
complexity = 4
|
||||
input_names = list(
|
||||
"frequency",
|
||||
"code"
|
||||
)
|
||||
activator_names = list(
|
||||
"send signal",
|
||||
"on signal received"
|
||||
)
|
||||
inputs = list("frequency","code")
|
||||
outputs = list()
|
||||
activators = list("send signal","on signal received")
|
||||
|
||||
var/frequency = 1457
|
||||
var/code = 30
|
||||
var/datum/radio_frequency/radio_connection
|
||||
|
||||
/obj/item/integrated_circuit/input/signaler/New()
|
||||
/obj/item/integrated_circuit/input/signaler/initialize()
|
||||
..()
|
||||
spawn(4 SECONDS)
|
||||
set_frequency(frequency)
|
||||
var/datum/integrated_io/new_freq = inputs[1]
|
||||
var/datum/integrated_io/new_code = inputs[2]
|
||||
@@ -233,7 +179,7 @@
|
||||
if(radio_controller)
|
||||
radio_controller.remove_object(src,frequency)
|
||||
frequency = 0
|
||||
..()
|
||||
. = ..()
|
||||
|
||||
/obj/item/integrated_circuit/input/signaler/on_data_written()
|
||||
var/datum/integrated_io/new_freq = inputs[1]
|
||||
@@ -244,8 +190,7 @@
|
||||
code = new_code.data
|
||||
|
||||
|
||||
/obj/item/integrated_circuit/input/signaler/work() // Sends a signal.
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/input/signaler/do_work() // Sends a signal.
|
||||
if(!radio_connection)
|
||||
return
|
||||
|
||||
@@ -282,10 +227,9 @@
|
||||
var/datum/integrated_io/A = activators[2]
|
||||
A.push_data()
|
||||
|
||||
for(var/mob/O in hearers(1, src.loc))
|
||||
for(var/mob/O in hearers(1, get_turf(src)))
|
||||
O.show_message(text("\icon[] *beep* *beep*", src), 3, "*beep* *beep*", 2)
|
||||
|
||||
|
||||
/obj/item/integrated_circuit/input/EPv2
|
||||
name = "\improper EPv2 circuit"
|
||||
desc = "Enables the sending and receiving of messages on the Exonet with the EPv2 protocol."
|
||||
@@ -293,31 +237,17 @@
|
||||
second pin on each side, with additonal data reserved for the third pin. When a message is received, the second activaiton pin \
|
||||
will pulse whatever's connected to it. Pulsing the first activation pin will send a message."
|
||||
icon_state = "signal"
|
||||
number_of_inputs = 3
|
||||
number_of_outputs = 3
|
||||
number_of_activators = 2
|
||||
complexity = 4
|
||||
input_names = list(
|
||||
"target EPv2 address",
|
||||
"data to send",
|
||||
"secondary text"
|
||||
)
|
||||
output_names = list(
|
||||
"address received",
|
||||
"data received",
|
||||
"secondary text received"
|
||||
)
|
||||
activator_names = list(
|
||||
"send data",
|
||||
"on data received"
|
||||
)
|
||||
inputs = list("target EPv2 address", "data to send", "secondary text")
|
||||
outputs = list("address received", "data received", "secondary text received")
|
||||
activators = list("send data", "on data received")
|
||||
var/datum/exonet_protocol/exonet = null
|
||||
|
||||
/obj/item/integrated_circuit/input/EPv2/New()
|
||||
..()
|
||||
exonet = new(src)
|
||||
exonet.make_address("EPv2_circuit-\ref[src]")
|
||||
desc += "This circuit's EPv2 address is: [exonet.address]."
|
||||
desc += "<br>This circuit's EPv2 address is: [exonet.address]."
|
||||
|
||||
/obj/item/integrated_circuit/input/EPv2/Destroy()
|
||||
if(exonet)
|
||||
@@ -325,8 +255,7 @@
|
||||
qdel(exonet)
|
||||
..()
|
||||
|
||||
/obj/item/integrated_circuit/input/EPv2/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/input/EPv2/do_work()
|
||||
var/datum/integrated_io/target_address = inputs[1]
|
||||
var/datum/integrated_io/message = inputs[2]
|
||||
var/datum/integrated_io/text = inputs[3]
|
||||
@@ -349,40 +278,33 @@
|
||||
name = "screen"
|
||||
desc = "This small screen can display a single piece of data, when the machine is examined closely."
|
||||
icon_state = "screen"
|
||||
complexity = 4
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 0
|
||||
number_of_activators = 1
|
||||
input_names = list(
|
||||
"displayed data"
|
||||
)
|
||||
activator_names = list(
|
||||
"load data"
|
||||
)
|
||||
inputs = list("displayed data")
|
||||
outputs = list()
|
||||
activators = list("load data")
|
||||
var/stuff_to_display = null
|
||||
|
||||
/obj/item/integrated_circuit/output/screen/work()
|
||||
/obj/item/integrated_circuit/output/screen/do_work()
|
||||
var/datum/integrated_io/I = inputs[1]
|
||||
if(isweakref(I.data))
|
||||
var/datum/d = I.data_as_type(/datum)
|
||||
if(d)
|
||||
stuff_to_display = "[d]"
|
||||
else
|
||||
stuff_to_display = I.data
|
||||
|
||||
/obj/item/integrated_circuit/output/light
|
||||
name = "light"
|
||||
desc = "This light can turn on and off on command."
|
||||
icon_state = "light_adv"
|
||||
// icon_state = "light"
|
||||
complexity = 4
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 0
|
||||
number_of_activators = 1
|
||||
activator_names = list(
|
||||
"toggle light"
|
||||
)
|
||||
inputs = list()
|
||||
outputs = list()
|
||||
activators = list("toggle light")
|
||||
var/light_toggled = 0
|
||||
var/light_brightness = 3
|
||||
var/light_rgb = "#FFFFFF"
|
||||
|
||||
/obj/item/integrated_circuit/output/light/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/output/light/do_work()
|
||||
light_toggled = !light_toggled
|
||||
update_lighting()
|
||||
|
||||
@@ -413,15 +335,13 @@
|
||||
desc = "This light can turn on and off on command, in any color, and in various brightness levels."
|
||||
icon_state = "light_adv"
|
||||
complexity = 8
|
||||
number_of_inputs = 4
|
||||
number_of_outputs = 0
|
||||
number_of_activators = 1
|
||||
input_names = list(
|
||||
inputs = list(
|
||||
"R",
|
||||
"G",
|
||||
"B",
|
||||
"Brightness"
|
||||
)
|
||||
outputs = list()
|
||||
|
||||
/obj/item/integrated_circuit/output/light/advanced/on_data_written()
|
||||
update_lighting()
|
||||
@@ -432,28 +352,36 @@
|
||||
icon_state = "speaker"
|
||||
complexity = 8
|
||||
cooldown_per_use = 4 SECONDS
|
||||
number_of_inputs = 3
|
||||
number_of_outputs = 0
|
||||
number_of_activators = 1
|
||||
input_names = list(
|
||||
inputs = list(
|
||||
"sound ID",
|
||||
"volume",
|
||||
"frequency"
|
||||
)
|
||||
activator_names = list(
|
||||
"play sound"
|
||||
)
|
||||
outputs = list()
|
||||
activators = list("play sound")
|
||||
var/list/sounds = list()
|
||||
category = /obj/item/integrated_circuit/output/sound
|
||||
|
||||
/obj/item/integrated_circuit/output/sound/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/output/sound/New()
|
||||
..()
|
||||
extended_desc = list()
|
||||
extended_desc += "The first input pin determines which sound is used. The choices are; "
|
||||
extended_desc += jointext(sounds, ", ")
|
||||
extended_desc += ". The second pin determines the volume of sound that is played"
|
||||
extended_desc += ", and the third determines if the frequency of the sound will vary with each activation."
|
||||
extended_desc = jointext(extended_desc, null)
|
||||
|
||||
/obj/item/integrated_circuit/output/sound/do_work()
|
||||
var/datum/integrated_io/ID = inputs[1]
|
||||
var/datum/integrated_io/vol = inputs[2]
|
||||
var/datum/integrated_io/frequency = inputs[3]
|
||||
if(istext(ID.data) && isnum(vol.data) && isnum(frequency.data))
|
||||
var/selected_sound = sounds[ID.data]
|
||||
vol.data = Clamp(vol.data, 0, 1)
|
||||
frequency.data = Clamp(frequency.data, 0, 100)
|
||||
if(!selected_sound)
|
||||
world << "No sound"
|
||||
return
|
||||
vol.data = Clamp(vol.data, 0, 100)
|
||||
frequency.data = round(Clamp(frequency.data, 0, 1))
|
||||
playsound(get_turf(src), selected_sound, vol.data, frequency.data, -1)
|
||||
|
||||
/obj/item/integrated_circuit/output/sound/beeper
|
||||
@@ -461,9 +389,6 @@
|
||||
desc = "A miniature speaker is attached to this component. This is often used in the construction of motherboards, which use \
|
||||
the speaker to tell the user if something goes very wrong when booting up. It can also do other similar synthetic sounds such \
|
||||
as buzzing, pinging, chiming, and more."
|
||||
extended_desc = "The first input pin determines what sound is used. The choices are; beep, chime, buzz sigh, buzz twice, ping, \
|
||||
synth yes, synth no, warning buzz. The second pin determines the volume of sound that is played, and the third determines if \
|
||||
the frequency of the sound will vary with each activation."
|
||||
sounds = list(
|
||||
"beep" = 'sound/machines/twobeep.ogg',
|
||||
"chime" = 'sound/machines/chime.ogg',
|
||||
@@ -478,9 +403,6 @@
|
||||
/obj/item/integrated_circuit/output/sound/beepsky
|
||||
name = "securitron sound circuit"
|
||||
desc = "A miniature speaker is attached to this component. Considered by some to be the essential component for a securitron."
|
||||
extended_desc = "The first input pin determines what sound is used. The choices are; creep, criminal, freeze, god, \
|
||||
i am the law, insult, radio, secure day. The second pin determines the volume of sound that is played, and the \
|
||||
third determines if the frequency of the sound will vary with each activation."
|
||||
sounds = list(
|
||||
"creep" = 'sound/voice/bcreep.ogg',
|
||||
"criminal" = 'sound/voice/bcriminal.ogg',
|
||||
@@ -491,4 +413,3 @@
|
||||
"radio" = 'sound/voice/bradio.ogg',
|
||||
"secure day" = 'sound/voice/bsecureday.ogg',
|
||||
)
|
||||
|
||||
|
||||
@@ -1,172 +1,106 @@
|
||||
/obj/item/integrated_circuit/logic
|
||||
name = "logic gate"
|
||||
desc = "This tiny chip will decide for you!"
|
||||
extended_desc = "Logic circuits will treat a null, 0, and a \"\" string value as FALSE and anything else as TRUE."
|
||||
complexity = 3
|
||||
number_of_inputs = 2
|
||||
number_of_outputs = 1
|
||||
number_of_activators = 2
|
||||
input_names = list(
|
||||
"A",
|
||||
"B"
|
||||
)
|
||||
output_names = list(
|
||||
"result"
|
||||
)
|
||||
activator_names = list(
|
||||
"compare",
|
||||
"on true result"
|
||||
)
|
||||
outputs = list("result")
|
||||
activators = list("compare", "on true result")
|
||||
category = /obj/item/integrated_circuit/logic
|
||||
|
||||
/obj/item/integrated_circuit/logic/equals
|
||||
/obj/item/integrated_circuit/logic/do_work()
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
var/datum/integrated_io/P = activators[2]
|
||||
O.push_data()
|
||||
if(O.data)
|
||||
P.push_data()
|
||||
|
||||
/obj/item/integrated_circuit/logic/binary
|
||||
inputs = list("A","B")
|
||||
category = /obj/item/integrated_circuit/logic/binary
|
||||
|
||||
/obj/item/integrated_circuit/logic/binary/do_work()
|
||||
var/datum/integrated_io/A = inputs[1]
|
||||
var/datum/integrated_io/B = inputs[2]
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
O.data = do_compare(A, B) ? TRUE : FALSE
|
||||
..()
|
||||
|
||||
/obj/item/integrated_circuit/logic/binary/proc/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B)
|
||||
return FALSE
|
||||
|
||||
/obj/item/integrated_circuit/logic/unary
|
||||
inputs = list("A")
|
||||
category = /obj/item/integrated_circuit/logic/unary
|
||||
|
||||
/obj/item/integrated_circuit/logic/unary/do_work()
|
||||
var/datum/integrated_io/A = inputs[1]
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
O.data = do_check(A) ? TRUE : FALSE
|
||||
..()
|
||||
|
||||
/obj/item/integrated_circuit/logic/unary/proc/do_check(var/datum/integrated_io/A)
|
||||
return FALSE
|
||||
|
||||
/obj/item/integrated_circuit/logic/binary/equals
|
||||
name = "equal gate"
|
||||
desc = "This gate compares two values, and outputs the number one if both are the same."
|
||||
icon_state = "equal"
|
||||
|
||||
/obj/item/integrated_circuit/logic/equals/work()
|
||||
if(..())
|
||||
var/datum/integrated_io/A = inputs[1]
|
||||
var/datum/integrated_io/B = inputs[2]
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
var/datum/integrated_io/P = activators[2]
|
||||
if(A.data == B.data)
|
||||
O.data = 1
|
||||
O.push_data()
|
||||
P.push_data()
|
||||
else
|
||||
O.data = 0
|
||||
/obj/item/integrated_circuit/logic/binary/equals/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B)
|
||||
return A.data == B.data
|
||||
|
||||
/obj/item/integrated_circuit/logic/not
|
||||
name = "not gate"
|
||||
desc = "This gate inverts what's fed into it."
|
||||
icon_state = "not"
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 1
|
||||
number_of_activators = 1
|
||||
output_names = list(
|
||||
"invert"
|
||||
)
|
||||
|
||||
|
||||
/obj/item/integrated_circuit/logic/not/work()
|
||||
if(..())
|
||||
var/datum/integrated_io/A = inputs[1]
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
if(A.data)
|
||||
O.data = !A.data
|
||||
O.push_data()
|
||||
else
|
||||
O.data = 0
|
||||
|
||||
/obj/item/integrated_circuit/logic/and
|
||||
/obj/item/integrated_circuit/logic/binary/and
|
||||
name = "and gate"
|
||||
desc = "This gate will output 'one' if both inputs evaluate to true."
|
||||
icon_state = "and"
|
||||
|
||||
/obj/item/integrated_circuit/logic/and/work()
|
||||
if(..())
|
||||
var/datum/integrated_io/A = inputs[1]
|
||||
var/datum/integrated_io/B = inputs[2]
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
var/datum/integrated_io/P = activators[2]
|
||||
if(A.data && B.data)
|
||||
O.data = 1
|
||||
O.push_data()
|
||||
A.push_data()
|
||||
P.push_data()
|
||||
else
|
||||
O.data = 0
|
||||
/obj/item/integrated_circuit/logic/binary/and/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B)
|
||||
return A.data && B.data
|
||||
|
||||
/obj/item/integrated_circuit/logic/or
|
||||
/obj/item/integrated_circuit/logic/binary/or
|
||||
name = "or gate"
|
||||
desc = "This gate will output 'one' if one of the inputs evaluate to true."
|
||||
icon_state = "or"
|
||||
|
||||
/obj/item/integrated_circuit/logic/or/work()
|
||||
if(..())
|
||||
var/datum/integrated_io/A = inputs[1]
|
||||
var/datum/integrated_io/B = inputs[2]
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
var/datum/integrated_io/P = activators[2]
|
||||
if(A.data || B.data)
|
||||
O.data = 1
|
||||
O.push_data()
|
||||
A.push_data()
|
||||
P.push_data()
|
||||
else
|
||||
O.data = 0
|
||||
/obj/item/integrated_circuit/logic/binary/or/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B)
|
||||
return A.data || B.data
|
||||
|
||||
/obj/item/integrated_circuit/logic/less_than
|
||||
/obj/item/integrated_circuit/logic/binary/less_than
|
||||
name = "less than gate"
|
||||
desc = "This will output 'one' if the first input is less than the second input."
|
||||
icon_state = "less_than"
|
||||
|
||||
/obj/item/integrated_circuit/logic/less_than/work()
|
||||
if(..())
|
||||
var/datum/integrated_io/A = inputs[1]
|
||||
var/datum/integrated_io/B = inputs[2]
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
var/datum/integrated_io/P = activators[2]
|
||||
if(A.data < B.data)
|
||||
O.data = 1
|
||||
O.push_data()
|
||||
A.push_data()
|
||||
P.push_data()
|
||||
else
|
||||
O.data = 0
|
||||
/obj/item/integrated_circuit/logic/binary/less_than/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B)
|
||||
return A.data < B.data
|
||||
|
||||
/obj/item/integrated_circuit/logic/less_than_or_equal
|
||||
/obj/item/integrated_circuit/logic/binary/less_than_or_equal
|
||||
name = "less than or equal gate"
|
||||
desc = "This will output 'one' if the first input is less than, or equal to the second input."
|
||||
icon_state = "less_than_or_equal"
|
||||
|
||||
/obj/item/integrated_circuit/logic/less_than_or_equal/work()
|
||||
if(..())
|
||||
var/datum/integrated_io/A = inputs[1]
|
||||
var/datum/integrated_io/B = inputs[2]
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
var/datum/integrated_io/P = activators[2]
|
||||
if(A.data <= B.data)
|
||||
O.data = 1
|
||||
O.push_data()
|
||||
A.push_data()
|
||||
P.push_data()
|
||||
else
|
||||
O.data = 0
|
||||
/obj/item/integrated_circuit/logic/binary/less_than_or_equal/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B)
|
||||
return A.data <= B.data
|
||||
|
||||
/obj/item/integrated_circuit/logic/greater_than
|
||||
/obj/item/integrated_circuit/logic/binary/greater_than
|
||||
name = "greater than gate"
|
||||
desc = "This will output 'one' if the first input is greater than the second input."
|
||||
icon_state = "greater_than"
|
||||
|
||||
/obj/item/integrated_circuit/logic/greater_than/work()
|
||||
if(..())
|
||||
var/datum/integrated_io/A = inputs[1]
|
||||
var/datum/integrated_io/B = inputs[2]
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
var/datum/integrated_io/P = activators[2]
|
||||
if(A.data > B.data)
|
||||
O.data = 1
|
||||
O.push_data()
|
||||
A.push_data()
|
||||
P.push_data()
|
||||
else
|
||||
O.data = 0
|
||||
/obj/item/integrated_circuit/logic/binary/greater_than/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B)
|
||||
return A.data > B.data
|
||||
|
||||
/obj/item/integrated_circuit/logic/greater_than_or_equal
|
||||
/obj/item/integrated_circuit/logic/binary/greater_than_or_equal
|
||||
name = "greater_than or equal gate"
|
||||
desc = "This will output 'one' if the first input is greater than, or equal to the second input."
|
||||
icon_state = "greater_than_or_equal"
|
||||
|
||||
/obj/item/integrated_circuit/logic/greater_than_or_equal/work()
|
||||
if(..())
|
||||
var/datum/integrated_io/A = inputs[1]
|
||||
var/datum/integrated_io/B = inputs[2]
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
var/datum/integrated_io/P = activators[2]
|
||||
if(A.data >= B.data)
|
||||
O.data = 1
|
||||
O.push_data()
|
||||
A.push_data()
|
||||
P.push_data()
|
||||
else
|
||||
O.data = 0
|
||||
/obj/item/integrated_circuit/logic/binary/greater_than_or_equal/do_compare(var/datum/integrated_io/A, var/datum/integrated_io/B)
|
||||
return A.data >= B.data
|
||||
|
||||
/obj/item/integrated_circuit/logic/unary/not
|
||||
name = "not gate"
|
||||
desc = "This gate inverts what's fed into it."
|
||||
icon_state = "not"
|
||||
|
||||
/obj/item/integrated_circuit/logic/unary/not/do_check(var/datum/integrated_io/A)
|
||||
return !A.data
|
||||
@@ -6,14 +6,12 @@
|
||||
The 'fire' activator will cause the mechanism to attempt to fire the weapon at the coordinates, if possible. Note that the \
|
||||
normal limitations to firearms, such as ammunition requirements and firing delays, still hold true if fired by the mechanism."
|
||||
complexity = 20
|
||||
number_of_inputs = 2
|
||||
number_of_outputs = 0
|
||||
number_of_activators = 1
|
||||
input_names = list(
|
||||
inputs = list(
|
||||
"target X rel",
|
||||
"target Y rel"
|
||||
)
|
||||
activator_names = list(
|
||||
outputs = list()
|
||||
activators = list(
|
||||
"fire"
|
||||
)
|
||||
var/obj/item/weapon/gun/installed_gun = null
|
||||
@@ -45,7 +43,7 @@
|
||||
else
|
||||
user << "<span class='notice'>There's no weapon to remove from the mechanism.</span>"
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/weapon_firing/work()
|
||||
/obj/item/integrated_circuit/manipulation/weapon_firing/do_work()
|
||||
if(..())
|
||||
if(!installed_gun)
|
||||
return
|
||||
@@ -95,21 +93,16 @@
|
||||
into the smoke clouds when activated."
|
||||
flags = OPENCONTAINER
|
||||
complexity = 20
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 0
|
||||
number_of_activators = 1
|
||||
cooldown_per_use = 30 SECONDS
|
||||
input_names = list()
|
||||
activator_names = list(
|
||||
"create smoke"
|
||||
)
|
||||
inputs = list()
|
||||
outputs = list()
|
||||
activators = list("create smoke")
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/smoke/New()
|
||||
..()
|
||||
create_reagents(100)
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/smoke/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/manipulation/smoke/do_work()
|
||||
playsound(src.loc, 'sound/effects/smoke.ogg', 50, 1, -3)
|
||||
var/datum/effect/effect/system/smoke_spread/chem/smoke_system = new()
|
||||
smoke_system.set_up(reagents, 10, 0, get_turf(src))
|
||||
@@ -135,18 +128,12 @@
|
||||
Pulsing the 'step towards dir' activator pin will cause the machine to move a meter in that direction, assuming it is not \
|
||||
being held, or anchored in some way."
|
||||
complexity = 20
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 0
|
||||
number_of_activators = 1
|
||||
input_names = list(
|
||||
"dir num"
|
||||
)
|
||||
activator_names = list(
|
||||
"step towards dir"
|
||||
)
|
||||
inputs = list("dir num")
|
||||
outputs = list()
|
||||
activators = list("step towards dir")
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/locomotion/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/manipulation/locomotion/do_work()
|
||||
..()
|
||||
var/turf/T = get_turf(src)
|
||||
if(istype(loc, /obj/item/device/electronic_assembly))
|
||||
var/obj/item/device/electronic_assembly/machine = loc
|
||||
|
||||
@@ -3,24 +3,27 @@
|
||||
desc = "This tiny chip can store one piece of data."
|
||||
icon_state = "memory"
|
||||
complexity = 1
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 1
|
||||
number_of_activators = 1
|
||||
activator_names = list(
|
||||
"set"
|
||||
)
|
||||
inputs = list("input pin 1")
|
||||
outputs = list("output pin 1")
|
||||
activators = list("set")
|
||||
category = /obj/item/integrated_circuit/memory
|
||||
|
||||
/obj/item/integrated_circuit/memory/examine(mob/user)
|
||||
..()
|
||||
var/i
|
||||
for(i = 1, i <= outputs.len, i++)
|
||||
var/datum/integrated_io/O = outputs[i]
|
||||
user << "\The [src] has [O.data ? "'O.data'" : "nothing"] saved to address [i]."
|
||||
var/data = "nothing"
|
||||
if(isweakref(O.data))
|
||||
var/datum/d = O.data_as_type(/datum)
|
||||
if(d)
|
||||
data = "[d]"
|
||||
else if(!isnull(O.data))
|
||||
data = O.data
|
||||
to_chat(user, "\The [src] has [data] saved to address [i].")
|
||||
|
||||
/obj/item/integrated_circuit/memory/work()
|
||||
if(..())
|
||||
var/i
|
||||
for(i = 1, i <= inputs.len, i++)
|
||||
/obj/item/integrated_circuit/memory/do_work()
|
||||
for(var/i = 1 to inputs.len)
|
||||
var/datum/integrated_io/I = inputs[i]
|
||||
var/datum/integrated_io/O = outputs[i]
|
||||
O.data = I.data
|
||||
@@ -30,72 +33,121 @@
|
||||
desc = "This circuit can store four pieces of data."
|
||||
icon_state = "memory4"
|
||||
complexity = 4
|
||||
number_of_inputs = 4
|
||||
number_of_outputs = 4
|
||||
inputs = list("input pin 1","input pin 2","input pin 3","input pin 4")
|
||||
outputs = list("output pin 1","output pin 2","output pin 3","output pin 4")
|
||||
|
||||
/obj/item/integrated_circuit/memory/large
|
||||
name = "large memory circuit"
|
||||
desc = "This big circuit can hold eight pieces of data."
|
||||
icon_state = "memory8"
|
||||
complexity = 8
|
||||
number_of_inputs = 8
|
||||
number_of_outputs = 8
|
||||
inputs = list(
|
||||
"input pin 1",
|
||||
"input pin 2",
|
||||
"input pin 3",
|
||||
"input pin 4",
|
||||
"input pin 5",
|
||||
"input pin 6",
|
||||
"input pin 7",
|
||||
"input pin 8")
|
||||
outputs = list(
|
||||
"output pin 1",
|
||||
"output pin 2",
|
||||
"output pin 3",
|
||||
"output pin 4",
|
||||
"output pin 5",
|
||||
"output pin 6",
|
||||
"output pin 7",
|
||||
"output pin 8")
|
||||
|
||||
/obj/item/integrated_circuit/memory/huge
|
||||
name = "large memory stick"
|
||||
desc = "This stick of memory can hold up up to sixteen pieces of data."
|
||||
icon_state = "memory16"
|
||||
complexity = 16
|
||||
number_of_inputs = 16
|
||||
number_of_outputs = 16
|
||||
inputs = list(
|
||||
"input pin 1",
|
||||
"input pin 2",
|
||||
"input pin 3",
|
||||
"input pin 4",
|
||||
"input pin 5",
|
||||
"input pin 6",
|
||||
"input pin 7",
|
||||
"input pin 8",
|
||||
"input pin 9",
|
||||
"input pin 10",
|
||||
"input pin 11",
|
||||
"input pin 12",
|
||||
"input pin 13",
|
||||
"input pin 14",
|
||||
"input pin 15",
|
||||
"input pin 16"
|
||||
)
|
||||
outputs = list(
|
||||
"output pin 1",
|
||||
"output pin 2",
|
||||
"output pin 3",
|
||||
"output pin 4",
|
||||
"output pin 5",
|
||||
"output pin 6",
|
||||
"output pin 7",
|
||||
"output pin 8",
|
||||
"output pin 9",
|
||||
"output pin 10",
|
||||
"output pin 11",
|
||||
"output pin 12",
|
||||
"output pin 13",
|
||||
"output pin 14",
|
||||
"output pin 15",
|
||||
"output pin 16")
|
||||
|
||||
/obj/item/integrated_circuit/memory/constant
|
||||
name = "constant chip"
|
||||
desc = "This tiny chip can store one piece of data, which cannot be overwritten without disassembly."
|
||||
icon_state = "memory"
|
||||
complexity = 1
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 1
|
||||
number_of_activators = 1
|
||||
activator_names = list(
|
||||
"push data"
|
||||
)
|
||||
inputs = list()
|
||||
outputs = list("output pin")
|
||||
activators = list("push data")
|
||||
var/accepting_refs = 0
|
||||
|
||||
/obj/item/integrated_circuit/memory/constant/work()
|
||||
/obj/item/integrated_circuit/memory/constant/do_work()
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
O.push_data()
|
||||
|
||||
/obj/item/integrated_circuit/memory/constant/attack_self(mob/user)
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
var/type_to_use = input("Please choose a type to use.","[src] type setting") as null|anything in list("string","number","ref", "null")
|
||||
if(!CanInteract(user, physical_state))
|
||||
return
|
||||
|
||||
var/new_data = null
|
||||
switch(type_to_use)
|
||||
if("string")
|
||||
accepting_refs = 0
|
||||
new_data = input("Now type in a string.","[src] string writing") as null|text
|
||||
if(istext(new_data))
|
||||
if(istext(new_data) && CanInteract(user, physical_state))
|
||||
O.data = new_data
|
||||
user << "<span class='notice'>You set \the [src]'s memory to [O.display_data()].</span>"
|
||||
to_chat(user, "<span class='notice'>You set \the [src]'s memory to [O.display_data()].</span>")
|
||||
if("number")
|
||||
accepting_refs = 0
|
||||
new_data = input("Now type in a number.","[src] number writing") as null|num
|
||||
if(isnum(new_data))
|
||||
if(isnum(new_data) && CanInteract(user, physical_state))
|
||||
O.data = new_data
|
||||
user << "<span class='notice'>You set \the [src]'s memory to [O.display_data()].</span>"
|
||||
to_chat(user, "<span class='notice'>You set \the [src]'s memory to [O.display_data()].</span>")
|
||||
if("ref")
|
||||
accepting_refs = 1
|
||||
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>"
|
||||
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("null")
|
||||
O.data = null
|
||||
user << "<span class='notice'>You set \the [src]'s memory to absolutely nothing.</span>"
|
||||
to_chat(user, "<span class='notice'>You set \the [src]'s memory to absolutely nothing.</span>")
|
||||
|
||||
/obj/item/integrated_circuit/memory/constant/afterattack(atom/target, mob/living/user, proximity)
|
||||
if(accepting_refs && proximity)
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
O.data = target
|
||||
O.data = weakref(target)
|
||||
visible_message("<span class='notice'>[user] slides \a [src]'s over \the [target].</span>")
|
||||
user << "<span class='notice'>You set \the [src]'s memory to a reference to [O.display_data()]. The ref scanner is \
|
||||
now off.</span>"
|
||||
to_chat(user, "<span class='notice'>You set \the [src]'s memory to a reference to [O.display_data()]. The ref scanner is \
|
||||
now off.</span>")
|
||||
accepting_refs = 0
|
||||
@@ -2,23 +2,21 @@
|
||||
name = "time circuit"
|
||||
desc = "Now you can build your own clock!"
|
||||
complexity = 2
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 0
|
||||
inputs = list()
|
||||
outputs = list()
|
||||
category = /obj/item/integrated_circuit/time
|
||||
|
||||
/obj/item/integrated_circuit/time/delay
|
||||
name = "two-sec delay circuit"
|
||||
desc = "This sends a pulse signal out after a delay, critical for ensuring proper control flow in a complex machine. \
|
||||
This circuit is set to send a pulse after a delay of two seconds."
|
||||
icon_state = "delay-20"
|
||||
number_of_activators = 2
|
||||
var/delay = 20
|
||||
activator_names = list(
|
||||
"incoming pulse",
|
||||
"outgoing pulse"
|
||||
)
|
||||
var/delay = 2 SECONDS
|
||||
activators = list("incoming pulse","outgoing pulse")
|
||||
|
||||
/obj/item/integrated_circuit/time/delay/do_work()
|
||||
set waitfor = 0 // Don't sleep in a proc that is called by a processor. It'll delay the entire thing
|
||||
|
||||
/obj/item/integrated_circuit/time/delay/work()
|
||||
if(..())
|
||||
var/datum/integrated_io/out_pulse = activators[2]
|
||||
sleep(delay)
|
||||
out_pulse.push_data()
|
||||
@@ -28,14 +26,14 @@
|
||||
desc = "This sends a pulse signal out after a delay, critical for ensuring proper control flow in a complex machine. \
|
||||
This circuit is set to send a pulse after a delay of five seconds."
|
||||
icon_state = "delay-50"
|
||||
delay = 50
|
||||
delay = 5 SECONDS
|
||||
|
||||
/obj/item/integrated_circuit/time/delay/one_sec
|
||||
name = "one-sec delay circuit"
|
||||
desc = "This sends a pulse signal out after a delay, critical for ensuring proper control flow in a complex machine. \
|
||||
This circuit is set to send a pulse after a delay of one second."
|
||||
icon_state = "delay-10"
|
||||
delay = 10
|
||||
delay = 1 SECOND
|
||||
|
||||
/obj/item/integrated_circuit/time/delay/half_sec
|
||||
name = "half-sec delay circuit"
|
||||
@@ -56,12 +54,9 @@
|
||||
desc = "This sends a pulse signal out after a delay, critical for ensuring proper control flow in a complex machine. \
|
||||
This circuit's delay can be customized, between 1/10th of a second to one hour. The delay is updated upon receiving a pulse."
|
||||
icon_state = "delay"
|
||||
number_of_inputs = 1
|
||||
input_names = list(
|
||||
"delay time",
|
||||
)
|
||||
inputs = list("delay time")
|
||||
|
||||
/obj/item/integrated_circuit/time/delay/custom/work()
|
||||
/obj/item/integrated_circuit/time/delay/custom/do_work()
|
||||
var/datum/integrated_io/delay_input = inputs[1]
|
||||
if(delay_input.data && isnum(delay_input.data) )
|
||||
var/new_delay = min(delay_input.data, 1)
|
||||
@@ -75,27 +70,35 @@
|
||||
desc = "This circuit sends an automatic pulse every four seconds."
|
||||
icon_state = "tick-m"
|
||||
complexity = 8
|
||||
number_of_inputs = 1
|
||||
number_of_activators = 1
|
||||
var/ticks_to_pulse = 2
|
||||
var/ticks_to_pulse = 4
|
||||
var/ticks_completed = 0
|
||||
input_names = list(
|
||||
"toggle ticking"
|
||||
)
|
||||
activator_names = list(
|
||||
"outgoing pulse"
|
||||
)
|
||||
|
||||
/obj/item/integrated_circuit/time/ticker/New()
|
||||
..()
|
||||
processing_objects |= src
|
||||
var/is_running = FALSE
|
||||
inputs = list("enable ticking")
|
||||
activators = list("outgoing pulse")
|
||||
|
||||
/obj/item/integrated_circuit/time/ticker/Destroy()
|
||||
if(is_running)
|
||||
processing_objects -= src
|
||||
. = ..()
|
||||
|
||||
/obj/item/integrated_circuit/time/ticker/on_data_written()
|
||||
var/datum/integrated_io/do_tick = inputs[1]
|
||||
if(do_tick.data && !is_running)
|
||||
is_running = TRUE
|
||||
processing_objects |= src
|
||||
else if(is_running)
|
||||
is_running = FALSE
|
||||
processing_objects -= src
|
||||
ticks_completed = 0
|
||||
|
||||
/obj/item/integrated_circuit/time/ticker/process()
|
||||
ticks_completed++
|
||||
if( (ticks_completed % ticks_to_pulse) == 0)
|
||||
var/process_ticks = process_schedule_interval("obj")
|
||||
ticks_completed += process_ticks
|
||||
if(ticks_completed >= ticks_to_pulse)
|
||||
if(ticks_to_pulse >= process_ticks)
|
||||
ticks_completed -= ticks_to_pulse
|
||||
else
|
||||
ticks_completed = 0
|
||||
var/datum/integrated_io/pulser = activators[1]
|
||||
pulser.push_data()
|
||||
|
||||
@@ -104,32 +107,23 @@
|
||||
desc = "This advanced circuit sends an automatic pulse every two seconds."
|
||||
icon_state = "tick-f"
|
||||
complexity = 12
|
||||
ticks_to_pulse = 1
|
||||
ticks_to_pulse = 2
|
||||
|
||||
/obj/item/integrated_circuit/time/ticker/slow
|
||||
name = "slow ticker"
|
||||
desc = "This simple circuit sends an automatic pulse every six seconds."
|
||||
icon_state = "tick-s"
|
||||
complexity = 4
|
||||
ticks_to_pulse = 3
|
||||
|
||||
ticks_to_pulse = 6
|
||||
|
||||
/obj/item/integrated_circuit/time/clock
|
||||
name = "integrated clock"
|
||||
desc = "Tells you what the local time is, specific to your station or planet."
|
||||
icon_state = "clock"
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 4
|
||||
number_of_activators = 1
|
||||
output_names = list(
|
||||
"time (string)",
|
||||
"hours (number)",
|
||||
"minutes (number)",
|
||||
"seconds (number)"
|
||||
)
|
||||
inputs = list()
|
||||
outputs = list("time (string)", "hours (number)", "minutes (number)", "seconds (number)")
|
||||
|
||||
/obj/item/integrated_circuit/time/clock/work()
|
||||
if(..())
|
||||
/obj/item/integrated_circuit/time/clock/do_work()
|
||||
var/datum/integrated_io/time = outputs[1]
|
||||
var/datum/integrated_io/hour = outputs[2]
|
||||
var/datum/integrated_io/min = outputs[3]
|
||||
|
||||
@@ -12,71 +12,64 @@
|
||||
icon = 'icons/obj/electronic_assemblies.dmi'
|
||||
icon_state = "wirer-wire"
|
||||
flags = CONDUCT
|
||||
w_class = ITEMSIZE_SMALL
|
||||
w_class = 2
|
||||
var/datum/integrated_io/selected_io = null
|
||||
var/mode = WIRE
|
||||
|
||||
/obj/item/device/integrated_electronics/wirer/New()
|
||||
..()
|
||||
|
||||
/obj/item/device/integrated_electronics/wirer/update_icon()
|
||||
icon_state = "wirer-[mode]"
|
||||
|
||||
/obj/item/device/integrated_electronics/wirer/proc/wire(var/datum/integrated_io/io, mob/user)
|
||||
if(mode == WIRE)
|
||||
selected_io = io
|
||||
user << "<span class='notice'>You attach a data wire to \the [selected_io.holder]'s [selected_io.name] data channel.</span>"
|
||||
to_chat(user, "<span class='notice'>You attach a data wire to \the [selected_io.holder]'s [selected_io.name] data channel.</span>")
|
||||
mode = WIRING
|
||||
update_icon()
|
||||
else if(mode == WIRING)
|
||||
if(io == selected_io)
|
||||
user << "<span class='warning'>Wiring \the [selected_io.holder]'s [selected_io.name] into itself is rather pointless.</span>"
|
||||
to_chat(user, "<span class='warning'>Wiring \the [selected_io.holder]'s [selected_io.name] into itself is rather pointless.</span>")
|
||||
return
|
||||
if(io.io_type != selected_io.io_type)
|
||||
user << "<span class='warning'>Those two types of channels are incompatable. The first is a [selected_io.io_type], \
|
||||
while the second is a [io.io_type].</span>"
|
||||
to_chat(user, "<span class='warning'>Those two types of channels are incompatable. The first is a [selected_io.io_type], \
|
||||
while the second is a [io.io_type].</span>")
|
||||
return
|
||||
selected_io.linked |= io
|
||||
io.linked |= selected_io
|
||||
|
||||
user << "<span class='notice'>You connect \the [selected_io.holder]'s [selected_io.name] to \the [io.holder]'s [io.name].</span>"
|
||||
to_chat(user, "<span class='notice'>You connect \the [selected_io.holder]'s [selected_io.name] to \the [io.holder]'s [io.name].</span>")
|
||||
mode = WIRE
|
||||
update_icon()
|
||||
//io.updateDialog()
|
||||
//selected_io.updateDialog()
|
||||
selected_io.holder.interact(user) // This is to update the UI.
|
||||
selected_io = null
|
||||
|
||||
else if(mode == UNWIRE)
|
||||
selected_io = io
|
||||
if(!io.linked.len)
|
||||
user << "<span class='warning'>There is nothing connected to \the [selected_io] data channel.</span>"
|
||||
to_chat(user, "<span class='warning'>There is nothing connected to \the [selected_io] data channel.</span>")
|
||||
selected_io = null
|
||||
return
|
||||
user << "<span class='notice'>You prepare to detach a data wire from \the [selected_io.holder]'s [selected_io.name] data channel.</span>"
|
||||
to_chat(user, "<span class='notice'>You prepare to detach a data wire from \the [selected_io.holder]'s [selected_io.name] data channel.</span>")
|
||||
mode = UNWIRING
|
||||
update_icon()
|
||||
return
|
||||
|
||||
else if(mode == UNWIRING)
|
||||
if(io == selected_io)
|
||||
user << "<span class='warning'>You can't wire a pin into each other, so unwiring \the [selected_io.holder] from \
|
||||
the same pin is rather moot.</span>"
|
||||
to_chat(user, "<span class='warning'>You can't wire a pin into each other, so unwiring \the [selected_io.holder] from \
|
||||
the same pin is rather moot.</span>")
|
||||
return
|
||||
if(selected_io in io.linked)
|
||||
io.linked.Remove(selected_io)
|
||||
selected_io.linked.Remove(io)
|
||||
user << "<span class='notice'>You disconnect \the [selected_io.holder]'s [selected_io.name] from \
|
||||
\the [io.holder]'s [io.name].</span>"
|
||||
//io.updateDialog()
|
||||
//selected_io.updateDialog()
|
||||
to_chat(user, "<span class='notice'>You disconnect \the [selected_io.holder]'s [selected_io.name] from \
|
||||
\the [io.holder]'s [io.name].</span>")
|
||||
selected_io.holder.interact(user) // This is to update the UI.
|
||||
selected_io = null
|
||||
mode = UNWIRE
|
||||
update_icon()
|
||||
else
|
||||
user << "<span class='warning'>\The [selected_io.holder]'s [selected_io.name] and \the [io.holder]'s \
|
||||
[io.name] are not connected.</span>"
|
||||
to_chat(user, "<span class='warning'>\The [selected_io.holder]'s [selected_io.name] and \the [io.holder]'s \
|
||||
[io.name] are not connected.</span>")
|
||||
return
|
||||
return
|
||||
|
||||
@@ -86,18 +79,18 @@
|
||||
mode = UNWIRE
|
||||
if(WIRING)
|
||||
if(selected_io)
|
||||
user << "<span class='notice'>You decide not to wire the data channel.</span>"
|
||||
to_chat(user, "<span class='notice'>You decide not to wire the data channel.</span>")
|
||||
selected_io = null
|
||||
mode = UNWIRE
|
||||
mode = WIRE
|
||||
if(UNWIRE)
|
||||
mode = WIRE
|
||||
if(UNWIRING)
|
||||
if(selected_io)
|
||||
user << "<span class='notice'>You decide not to disconnect the data channel.</span>"
|
||||
to_chat(user, "<span class='notice'>You decide not to disconnect the data channel.</span>")
|
||||
selected_io = null
|
||||
mode = UNWIRE
|
||||
update_icon()
|
||||
user << "<span class='notice'>You set \the [src] to [mode].</span>"
|
||||
to_chat(user, "<span class='notice'>You set \the [src] to [mode].</span>")
|
||||
|
||||
#undef WIRE
|
||||
#undef WIRING
|
||||
@@ -111,49 +104,52 @@
|
||||
icon = 'icons/obj/electronic_assemblies.dmi'
|
||||
icon_state = "debugger"
|
||||
flags = CONDUCT
|
||||
w_class = ITEMSIZE_SMALL
|
||||
w_class = 2
|
||||
var/data_to_write = null
|
||||
var/accepting_refs = 0
|
||||
|
||||
/obj/item/device/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")
|
||||
if(!CanInteract(user, physical_state))
|
||||
return
|
||||
|
||||
var/new_data = null
|
||||
switch(type_to_use)
|
||||
if("string")
|
||||
accepting_refs = 0
|
||||
new_data = input("Now type in a string.","[src] string writing") as null|text
|
||||
if(istext(new_data))
|
||||
if(istext(new_data) && CanInteract(user, physical_state))
|
||||
data_to_write = new_data
|
||||
user << "<span class='notice'>You set \the [src]'s memory to \"[new_data]\".</span>"
|
||||
to_chat(user, "<span class='notice'>You set \the [src]'s memory to \"[new_data]\".</span>")
|
||||
if("number")
|
||||
accepting_refs = 0
|
||||
new_data = input("Now type in a number.","[src] number writing") as null|num
|
||||
if(isnum(new_data))
|
||||
if(isnum(new_data) && CanInteract(user, physical_state))
|
||||
data_to_write = new_data
|
||||
user << "<span class='notice'>You set \the [src]'s memory to [new_data].</span>"
|
||||
to_chat(user, "<span class='notice'>You set \the [src]'s memory to [new_data].</span>")
|
||||
if("ref")
|
||||
accepting_refs = 1
|
||||
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>"
|
||||
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("null")
|
||||
data_to_write = null
|
||||
user << "<span class='notice'>You set \the [src]'s memory to absolutely nothing.</span>"
|
||||
to_chat(user, "<span class='notice'>You set \the [src]'s memory to absolutely nothing.</span>")
|
||||
|
||||
/obj/item/device/integrated_electronics/debugger/afterattack(atom/target, mob/living/user, proximity)
|
||||
if(accepting_refs && proximity)
|
||||
data_to_write = target
|
||||
visible_message("<span class='notice'>[user] slides \a [src]'s over \the [target].</span>")
|
||||
user << "<span class='notice'>You set \the [src]'s memory to a reference to [target.name] \[Ref\]. The ref scanner is \
|
||||
now off.</span>"
|
||||
to_chat(user, "<span class='notice'>You set \the [src]'s memory to a reference to [target.name] \[Ref\]. The ref scanner is \
|
||||
now off.</span>")
|
||||
accepting_refs = 0
|
||||
|
||||
/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)
|
||||
user << "<span class='notice'>You write [data_to_write] to \the [io.holder]'s [io].</span>"
|
||||
to_chat(user, "<span class='notice'>You write '[data_to_write ? data_to_write : "NULL"]' to the '[io]' pin of \the [io.holder].</span>")
|
||||
else if(io.io_type == PULSE_CHANNEL)
|
||||
io.holder.work()
|
||||
user << "<span class='notice'>You pulse \the [io.holder]'s [io].</span>"
|
||||
io.holder.check_then_do_work()
|
||||
to_chat(user, "<span class='notice'>You pulse \the [io.holder]'s [io].</span>")
|
||||
|
||||
io.holder.interact(user) // This is to update the UI.
|
||||
|
||||
@@ -162,13 +158,8 @@
|
||||
desc = "This kit's essential for any circuitry projects."
|
||||
icon = 'icons/obj/electronic_assemblies.dmi'
|
||||
icon_state = "circuit_kit"
|
||||
w_class = ITEMSIZE_NORMAL
|
||||
storage_slots = 200
|
||||
max_storage_space = ITEMSIZE_COST_NORMAL * 100
|
||||
max_w_class = ITEMSIZE_NORMAL
|
||||
w_class = 3
|
||||
display_contents_with_number = 1
|
||||
can_hold = list(/obj/item/integrated_circuit, /obj/item/device/integrated_electronics, /obj/item/device/electronic_assembly,
|
||||
/obj/item/weapon/screwdriver, /obj/item/weapon/crowbar)
|
||||
|
||||
/obj/item/weapon/storage/bag/circuits/basic/New()
|
||||
..()
|
||||
@@ -199,29 +190,32 @@
|
||||
)
|
||||
|
||||
for(var/thing in types_to_spawn)
|
||||
var/i = 3
|
||||
while(i)
|
||||
var/obj/item/integrated_circuit/ic = thing
|
||||
if(initial(ic.category) == thing)
|
||||
continue
|
||||
|
||||
for(var/i = 1 to 4)
|
||||
new thing(src)
|
||||
i--
|
||||
|
||||
new /obj/item/device/electronic_assembly(src)
|
||||
new /obj/item/device/integrated_electronics/wirer(src)
|
||||
new /obj/item/device/integrated_electronics/debugger(src)
|
||||
new /obj/item/weapon/crowbar(src)
|
||||
new /obj/item/weapon/screwdriver(src)
|
||||
make_exact_fit()
|
||||
|
||||
/obj/item/weapon/storage/bag/circuits/all/New()
|
||||
..()
|
||||
var/list/types_to_spawn = typesof(/obj/item/integrated_circuit)
|
||||
|
||||
for(var/thing in types_to_spawn)
|
||||
var/i = 10
|
||||
while(i)
|
||||
for(var/thing in subtypesof(/obj/item/integrated_circuit))
|
||||
var/obj/item/integrated_circuit/ic = thing
|
||||
if(initial(ic.category) == thing)
|
||||
continue
|
||||
for(var/i = 1 to 10)
|
||||
new thing(src)
|
||||
i--
|
||||
|
||||
new /obj/item/device/electronic_assembly(src)
|
||||
new /obj/item/device/integrated_electronics/wirer(src)
|
||||
new /obj/item/device/integrated_electronics/debugger(src)
|
||||
new /obj/item/weapon/crowbar(src)
|
||||
new /obj/item/weapon/screwdriver(src)
|
||||
make_exact_fit()
|
||||
6
code/modules/integrated_electronics/~defines.dm
Normal file
6
code/modules/integrated_electronics/~defines.dm
Normal file
@@ -0,0 +1,6 @@
|
||||
#undef IC_INPUT
|
||||
#undef IC_OUTPUT
|
||||
#undef IC_ACTIVATOR
|
||||
|
||||
#undef DATA_CHANNEL
|
||||
#undef PULSE_CHANNEL
|
||||
@@ -1754,44 +1754,44 @@ CIRCUITS BELOW
|
||||
..()
|
||||
name = "Custom circuitry \[Logic\] ([item_name])"
|
||||
|
||||
/datum/design/circuit/integrated_circuit/logic/equals
|
||||
/datum/design/circuit/integrated_circuit/logic/binary/equals
|
||||
id = "cc-equals"
|
||||
build_path = /obj/item/integrated_circuit/logic/equals
|
||||
build_path = /obj/item/integrated_circuit/logic/binary/equals
|
||||
sort_string = "WAAFA"
|
||||
|
||||
/datum/design/circuit/integrated_circuit/logic/not
|
||||
/datum/design/circuit/integrated_circuit/logic/unary/not
|
||||
id = "cc-not"
|
||||
build_path = /obj/item/integrated_circuit/logic/not
|
||||
build_path = /obj/item/integrated_circuit/logic/unary/not
|
||||
sort_string = "WAAFB"
|
||||
|
||||
/datum/design/circuit/integrated_circuit/logic/and
|
||||
/datum/design/circuit/integrated_circuit/logic/binary/and
|
||||
id = "cc-and"
|
||||
build_path = /obj/item/integrated_circuit/logic/and
|
||||
build_path = /obj/item/integrated_circuit/logic/binary/and
|
||||
sort_string = "WAAFC"
|
||||
|
||||
/datum/design/circuit/integrated_circuit/logic/or
|
||||
/datum/design/circuit/integrated_circuit/logic/binary/or
|
||||
id = "cc-or"
|
||||
build_path = /obj/item/integrated_circuit/logic/or
|
||||
build_path = /obj/item/integrated_circuit/logic/binary/or
|
||||
sort_string = "WAAFD"
|
||||
|
||||
/datum/design/circuit/integrated_circuit/logic/less_than
|
||||
/datum/design/circuit/integrated_circuit/logic/binary/less_than
|
||||
id = "cc-less_than"
|
||||
build_path = /obj/item/integrated_circuit/logic/less_than
|
||||
build_path = /obj/item/integrated_circuit/logic/binary/less_than
|
||||
sort_string = "WAAFE"
|
||||
|
||||
/datum/design/circuit/integrated_circuit/logic/less_than_or_equal
|
||||
/datum/design/circuit/integrated_circuit/logic/binary/less_than_or_equal
|
||||
id = "cc-less_than_or_equal"
|
||||
build_path = /obj/item/integrated_circuit/logic/less_than_or_equal
|
||||
build_path = /obj/item/integrated_circuit/logic/binary/less_than_or_equal
|
||||
sort_string = "WAAFF"
|
||||
|
||||
/datum/design/circuit/integrated_circuit/logic/greater_than
|
||||
/datum/design/circuit/integrated_circuit/logic/binary/greater_than
|
||||
id = "cc-greater_than"
|
||||
build_path = /obj/item/integrated_circuit/logic/greater_than
|
||||
build_path = /obj/item/integrated_circuit/logic/binary/greater_than
|
||||
sort_string = "WAAFG"
|
||||
|
||||
/datum/design/circuit/integrated_circuit/logic/greater_than_or_equal
|
||||
/datum/design/circuit/integrated_circuit/logic/binary/greater_than_or_equal
|
||||
id = "cc-greater_than_or_equal"
|
||||
build_path = /obj/item/integrated_circuit/logic/greater_than_or_equal
|
||||
build_path = /obj/item/integrated_circuit/logic/binary/greater_than_or_equal
|
||||
sort_string = "WAAFH"
|
||||
|
||||
|
||||
|
||||
@@ -170,6 +170,7 @@
|
||||
#include "code\datums\progressbar.dm"
|
||||
#include "code\datums\recipe.dm"
|
||||
#include "code\datums\sun.dm"
|
||||
#include "code\datums\weakref.dm"
|
||||
#include "code\datums\autolathe\arms.dm"
|
||||
#include "code\datums\autolathe\autolathe.dm"
|
||||
#include "code\datums\autolathe\devices.dm"
|
||||
@@ -1378,6 +1379,7 @@
|
||||
#include "code\modules\integrated_electronics\memory.dm"
|
||||
#include "code\modules\integrated_electronics\time.dm"
|
||||
#include "code\modules\integrated_electronics\tools.dm"
|
||||
#include "code\modules\integrated_electronics\~defines.dm"
|
||||
#include "code\modules\library\lib_items.dm"
|
||||
#include "code\modules\library\lib_machines.dm"
|
||||
#include "code\modules\library\lib_readme.dm"
|
||||
|
||||
Reference in New Issue
Block a user