mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
work
This commit is contained in:
175
code/modules/integrated_electronics/_defines.dm
Normal file
175
code/modules/integrated_electronics/_defines.dm
Normal file
@@ -0,0 +1,175 @@
|
||||
#define DATA_CHANNEL "data channel"
|
||||
#define PULSE_CHANNEL "pulse channel"
|
||||
|
||||
/obj/item/integrated_circuit
|
||||
name = "integrated circuit"
|
||||
desc = "It's a tiny chip! This one doesn't seem to do much, however."
|
||||
icon = 'icons/obj/electronic_assemblies.dmi'
|
||||
icon_state = "template"
|
||||
w_class = 1
|
||||
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/complexity = 1 //This acts as a limitation on building machines, more resource-intensive components cost more 'space'.
|
||||
var/power_required = 5 //w
|
||||
|
||||
/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"]."
|
||||
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()]."
|
||||
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()]."
|
||||
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()]."
|
||||
|
||||
/obj/item/integrated_circuit/New()
|
||||
..()
|
||||
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 outputs)
|
||||
A.name = "[activator_names[i]]"
|
||||
i++
|
||||
|
||||
/obj/item/integrated_circuit/Destroy()
|
||||
for(var/datum/integrated_io/I in inputs)
|
||||
qdel(I)
|
||||
for(var/datum/integrated_io/O in outputs)
|
||||
qdel(O)
|
||||
for(var/datum/integrated_io/A in activators)
|
||||
qdel(A)
|
||||
..()
|
||||
|
||||
/obj/item/integrated_circuit/verb/rename_component()
|
||||
set name = "Rename Circuit"
|
||||
set category = "Object"
|
||||
set desc = "Rename your circuit, useful to stay organized."
|
||||
|
||||
var/mob/M = usr
|
||||
|
||||
var/input = sanitizeSafe(input("What do you want to name the circuit?", ,""), MAX_NAME_LEN)
|
||||
|
||||
if(src && input)
|
||||
M << "<span class='notice'>The circuit '[src.name]' is now labeled '[input]'.</span>"
|
||||
name = input
|
||||
|
||||
/datum/integrated_io
|
||||
var/name = "input/output"
|
||||
var/obj/item/integrated_circuit/holder = null
|
||||
var/data = null
|
||||
// var/datum/integrated_io/linked = null
|
||||
var/list/linked = list()
|
||||
var/io_type = DATA_CHANNEL
|
||||
|
||||
/datum/integrated_io/New(var/newloc)
|
||||
..()
|
||||
holder = newloc
|
||||
if(!holder)
|
||||
message_admins("ERROR: An integrated_io ([src.name]) spawned without a holder! This is a bug.")
|
||||
|
||||
/datum/integrated_io/Destroy()
|
||||
disconnect()
|
||||
holder = null
|
||||
..()
|
||||
|
||||
/datum/integrated_io/proc/push_data()
|
||||
if(linked.len)
|
||||
for(var/datum/integrated_io/io in linked)
|
||||
io.data = data
|
||||
|
||||
/datum/integrated_io/activate/push_data()
|
||||
if(linked.len)
|
||||
for(var/datum/integrated_io/io in linked)
|
||||
io.holder.work()
|
||||
|
||||
/datum/integrated_io/proc/pull_data()
|
||||
if(linked.len)
|
||||
for(var/datum/integrated_io/io in linked)
|
||||
data = io.data
|
||||
|
||||
/datum/integrated_io/proc/get_linked_to_desc()
|
||||
if(linked.len)
|
||||
var/result = english_list(linked)
|
||||
return "the [result]"
|
||||
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.
|
||||
for(var/datum/integrated_io/their_linked_io in their_io.linked)
|
||||
if(their_linked_io == src)
|
||||
their_io.linked.Remove(src)
|
||||
else
|
||||
continue
|
||||
//Now that we're removed from them, we gotta remove them from us.
|
||||
src.linked.Remove(their_io)
|
||||
|
||||
/datum/integrated_io/input
|
||||
name = "input pin"
|
||||
|
||||
/datum/integrated_io/output
|
||||
name = "output pin"
|
||||
|
||||
/datum/integrated_io/activate
|
||||
name = "activation pin"
|
||||
io_type = PULSE_CHANNEL
|
||||
|
||||
/obj/item/integrated_circuit/proc/push_data()
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
O.push_data()
|
||||
|
||||
/obj/item/integrated_circuit/proc/pull_data()
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.push_data()
|
||||
|
||||
/obj/item/integrated_circuit/proc/work()
|
||||
last_used = world.time
|
||||
return
|
||||
|
||||
/obj/item/integrated_circuit/proc/disconnect_all()
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.disconnect()
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
O.disconnect()
|
||||
for(var/datum/integrated_io/activate/A in activators)
|
||||
A.disconnect()
|
||||
6
code/modules/integrated_electronics/_limits.dm
Normal file
6
code/modules/integrated_electronics/_limits.dm
Normal file
@@ -0,0 +1,6 @@
|
||||
#define MAX_NUMBER_MEMORY 10000
|
||||
#define MIN_NUMBER_MEMORY -10000
|
||||
#define MAX_STRING_MEMORY_LENGTH 20
|
||||
#define MAX_STRING_CONCATINATOR_LENGTH 250
|
||||
#define MIN_PULSER_TICK 5 SECONDS
|
||||
#define DEFAULT_PART_COOLDOWN 3 SECONDS
|
||||
157
code/modules/integrated_electronics/arithmetic.dm
Normal file
157
code/modules/integrated_electronics/arithmetic.dm
Normal file
@@ -0,0 +1,157 @@
|
||||
//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"
|
||||
)
|
||||
|
||||
// +Adding+ //
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/addition
|
||||
name = "addition circuit"
|
||||
desc = "This circuit can add numbers together."
|
||||
icon_state = "addition"
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/addition/work()
|
||||
var/result = 0
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.pull_data()
|
||||
if(isnum(I.data))
|
||||
result = result + I.data
|
||||
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
O.data = result
|
||||
O.push_data()
|
||||
..()
|
||||
|
||||
// -Subtracting- //
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/subtraction
|
||||
name = "subtraction circuit"
|
||||
desc = "This circuit can subtract numbers."
|
||||
icon_state = "subtraction"
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/subtraction/work()
|
||||
var/result = 0
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.pull_data()
|
||||
if(isnum(I.data))
|
||||
result = result - I.data
|
||||
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
O.data = result
|
||||
O.push_data()
|
||||
..()
|
||||
|
||||
// *Multiply* //
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/multiplication
|
||||
name = "multiplication circuit"
|
||||
desc = "This circuit can multiply numbers."
|
||||
icon_state = "multiplication"
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/subtraction/work()
|
||||
var/result = 0
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.pull_data()
|
||||
if(isnum(I.data))
|
||||
result = result * I.data
|
||||
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
O.data = result
|
||||
O.push_data()
|
||||
..()
|
||||
|
||||
// /Division/ //
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/division
|
||||
name = "division circuit"
|
||||
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()
|
||||
var/result = 0
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.pull_data()
|
||||
if(isnum(I.data) && I.data != 0) //No runtimes here.
|
||||
result = result / I.data
|
||||
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
O.data = result
|
||||
O.push_data()
|
||||
..()
|
||||
|
||||
// Absolute //
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/absolute
|
||||
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
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/absolute/work()
|
||||
var/result = 0
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.pull_data()
|
||||
if(isnum(I.data) && I.data != 0)
|
||||
result = abs(result)
|
||||
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
O.data = result
|
||||
O.push_data()
|
||||
..()
|
||||
|
||||
// Averaging //
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/average
|
||||
name = "average circuit"
|
||||
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()
|
||||
var/result = 0
|
||||
var/inputs_used = 0
|
||||
for(var/datum/integrated_io/input/I in inputs)
|
||||
I.pull_data()
|
||||
if(isnum(I.data))
|
||||
inputs_used++
|
||||
result = result + I.data
|
||||
|
||||
if(inputs_used)
|
||||
result = result / inputs_used
|
||||
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
O.data = result
|
||||
O.push_data()
|
||||
..()
|
||||
|
||||
// Pi, because why the hell not? //
|
||||
/obj/item/integrated_circuit/arithmetic/pi
|
||||
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
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/pi/work()
|
||||
var/datum/integrated_io/output/O = outputs[1]
|
||||
O.data = 3.14159
|
||||
O.push_data()
|
||||
..()
|
||||
79
code/modules/integrated_electronics/assemblies.dm
Normal file
79
code/modules/integrated_electronics/assemblies.dm
Normal file
@@ -0,0 +1,79 @@
|
||||
/obj/item/device/electronic_assembly
|
||||
name = "electronic assembly"
|
||||
desc = "It's a case, for building electronics with."
|
||||
w_class = 2
|
||||
icon = 'icons/obj/electronic_assemblies.dmi'
|
||||
icon_state = "setup"
|
||||
var/max_components = 10
|
||||
var/max_complexity = 30
|
||||
|
||||
/obj/item/device/electronic_assembly/medium
|
||||
name = "electronic setup"
|
||||
w_class = 3
|
||||
max_components = 20
|
||||
max_complexity = 50
|
||||
|
||||
/obj/item/device/electronic_assembly/large
|
||||
name = "electronic device"
|
||||
w_class = 4
|
||||
max_components = 30
|
||||
max_complexity = 60
|
||||
|
||||
/*
|
||||
|
||||
/obj/item/device/electronic_assembly/New()
|
||||
..()
|
||||
processing_objects |= src
|
||||
|
||||
/obj/item/device/electronic_assembly/Destroy()
|
||||
processing_objects.Remove(src)
|
||||
..()
|
||||
|
||||
/obj/item/device/electronic_assembly/process()
|
||||
for(var/obj/item/integrated_circuit/IC in contents)
|
||||
IC.work()
|
||||
*/
|
||||
|
||||
/obj/item/device/electronic_assembly/examine(mob/user)
|
||||
..()
|
||||
for(var/obj/item/integrated_circuit/output/screen/S in contents)
|
||||
if(S.stuff_to_display)
|
||||
user << "There's a little screen which displays '[S.stuff_to_display]'."
|
||||
|
||||
/obj/item/device/electronic_assembly/attackby(var/obj/item/I, var/mob/user)
|
||||
if(istype(I, /obj/item/integrated_circuit))
|
||||
var/obj/item/integrated_circuit/IC = I
|
||||
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
|
||||
|
||||
if( (total_parts + 1) >= max_components)
|
||||
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
|
||||
if( (total_complexity + IC.complexity) >= max_complexity)
|
||||
user << "<span class='warning'>You can't seem to add this [IC.name], since there's no more room.</span>"
|
||||
return 0
|
||||
|
||||
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/crowbar))
|
||||
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)
|
||||
|
||||
/obj/item/device/electronic_assembly/attack_self(mob/user)
|
||||
var/list/available_inputs = list()
|
||||
for(var/obj/item/integrated_circuit/input/input in contents)
|
||||
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)
|
||||
choice.ask_for_input(user)
|
||||
77
code/modules/integrated_electronics/data_transfer.dm
Normal file
77
code/modules/integrated_electronics/data_transfer.dm
Normal file
@@ -0,0 +1,77 @@
|
||||
/obj/item/integrated_circuit/transfer/splitter
|
||||
name = "splitter"
|
||||
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"
|
||||
)
|
||||
|
||||
/obj/item/integrated_circuit/transfer/splitter/medium
|
||||
name = "four splitter"
|
||||
icon_state = "splitter4"
|
||||
complexity = 5
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 4
|
||||
|
||||
/obj/item/integrated_circuit/transfer/splitter/large
|
||||
name = "eight splitter"
|
||||
icon_state = "splitter8"
|
||||
complexity = 9
|
||||
number_of_inputs = 1
|
||||
number_of_outputs = 8
|
||||
|
||||
/obj/item/integrated_circuit/transfer/splitter/work()
|
||||
var/datum/integrated_io/I = inputs[1]
|
||||
for(var/datum/integrated_io/output/O in outputs)
|
||||
O.data = I.data
|
||||
|
||||
/obj/item/integrated_circuit/transfer/activator_splitter
|
||||
name = "activator splitter"
|
||||
desc = "Splits incoming activation pulses into all of the output pins."
|
||||
icon_state = "splitter"
|
||||
complexity = 3
|
||||
number_of_activators = 3
|
||||
activator_names = list(
|
||||
"incoming pulse",
|
||||
"outgoing pulse A",
|
||||
"outgoing pulse B",
|
||||
"outgoing pulse C",
|
||||
"outgoing pulse D",
|
||||
"outgoing pulse E",
|
||||
"outgoing pulse F",
|
||||
"outgoing pulse G",
|
||||
"outgoing pulse H"
|
||||
)
|
||||
|
||||
/obj/item/integrated_circuit/transfer/activator_splitter/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.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
|
||||
66
code/modules/integrated_electronics/input_output.dm
Normal file
66
code/modules/integrated_electronics/input_output.dm
Normal file
@@ -0,0 +1,66 @@
|
||||
/obj/item/integrated_circuit/input/proc/ask_for_input(mob/user)
|
||||
return
|
||||
|
||||
/obj/item/integrated_circuit/input/button
|
||||
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
|
||||
activator_names = 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>"
|
||||
|
||||
/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
|
||||
output_names = list(
|
||||
"number entered"
|
||||
)
|
||||
activator_names = 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 num
|
||||
if(new_input && isnum(new_input))
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
O.data = new_input
|
||||
O.push_data()
|
||||
var/datum/integrated_io/A = activators[1]
|
||||
if(A.linked)
|
||||
A.holder.work()
|
||||
|
||||
/obj/item/integrated_circuit/output/screen
|
||||
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"
|
||||
)
|
||||
var/stuff_to_display = null
|
||||
|
||||
/obj/item/integrated_circuit/output/screen/work()
|
||||
var/datum/integrated_io/I = inputs[1]
|
||||
stuff_to_display = I.data
|
||||
166
code/modules/integrated_electronics/logic.dm
Normal file
166
code/modules/integrated_electronics/logic.dm
Normal file
@@ -0,0 +1,166 @@
|
||||
/obj/item/integrated_circuit/logic
|
||||
name = "logic gate"
|
||||
desc = "This tiny chip will decide for you!"
|
||||
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"
|
||||
)
|
||||
|
||||
/obj/item/integrated_circuit/logic/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()
|
||||
..()
|
||||
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/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()
|
||||
..()
|
||||
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
|
||||
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()
|
||||
..()
|
||||
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()
|
||||
else
|
||||
O.data = 0
|
||||
|
||||
/obj/item/integrated_circuit/logic/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()
|
||||
..()
|
||||
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()
|
||||
else
|
||||
O.data = 0
|
||||
|
||||
/obj/item/integrated_circuit/logic/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()
|
||||
..()
|
||||
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()
|
||||
else
|
||||
O.data = 0
|
||||
|
||||
/obj/item/integrated_circuit/logic/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()
|
||||
..()
|
||||
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()
|
||||
else
|
||||
O.data = 0
|
||||
|
||||
/obj/item/integrated_circuit/logic/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/geater_than/work()
|
||||
..()
|
||||
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()
|
||||
else
|
||||
O.data = 0
|
||||
|
||||
/obj/item/integrated_circuit/logic/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()
|
||||
..()
|
||||
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()
|
||||
else
|
||||
O.data = 0
|
||||
81
code/modules/integrated_electronics/memory.dm
Normal file
81
code/modules/integrated_electronics/memory.dm
Normal file
@@ -0,0 +1,81 @@
|
||||
/obj/item/integrated_circuit/memory
|
||||
name = "memory chip"
|
||||
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"
|
||||
)
|
||||
|
||||
/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]."
|
||||
|
||||
/obj/item/integrated_circuit/memory/work()
|
||||
var/i
|
||||
for(i = 1, i <= inputs.len, i++)
|
||||
var/datum/integrated_io/I = inputs[i]
|
||||
var/datum/integrated_io/O = outputs[i]
|
||||
O.data = I.data
|
||||
|
||||
/obj/item/integrated_circuit/memory/medium
|
||||
name = "memory circuit"
|
||||
desc = "This circuit can store four pieces of data."
|
||||
icon_state = "memory4"
|
||||
complexity = 4
|
||||
number_of_inputs = 4
|
||||
number_of_outputs = 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
|
||||
|
||||
/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
|
||||
|
||||
/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(
|
||||
"trigger output"
|
||||
)
|
||||
|
||||
/obj/item/integrated_circuit/memory/constant/work()
|
||||
var/datum/integrated_io/O = outputs[1]
|
||||
O.push_data()
|
||||
|
||||
/obj/item/integrated_circuit/memory/constant/attack_hand(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")
|
||||
var/new_data = null
|
||||
switch(type_to_use)
|
||||
if("string")
|
||||
new_data = input("Now type in a string.","[src] string writing") as null|text
|
||||
if(istext(new_data))
|
||||
O.data = new_data
|
||||
user << "<span class='notice'>You set \the [src]'s memory to '[new_data]'.</span>"
|
||||
if("number")
|
||||
new_data = input("Now type in a number.","[src] number writing") as null|num
|
||||
if(isnum(new_data))
|
||||
O.data = new_data
|
||||
user << "<span class='notice'>You set \the [src]'s memory to '[new_data]'.</span>"
|
||||
16
code/modules/integrated_electronics/power.dm
Normal file
16
code/modules/integrated_electronics/power.dm
Normal file
@@ -0,0 +1,16 @@
|
||||
/obj/item/integrated_circuit/power
|
||||
var/charge = 0
|
||||
var/max_charge = 0
|
||||
var/power_generated = 0
|
||||
|
||||
/obj/item/integrated_circuit/power/battery
|
||||
name = "micro powercell"
|
||||
desc = "An extremely small powercell, often used to power basic electronics, as a powersource or to use as a buffer."
|
||||
charge = 30
|
||||
max_charge = 30
|
||||
|
||||
/obj/item/integrated_circuit/power/solar
|
||||
name = "micro photovoltaic cell"
|
||||
desc = "A tiny solar cell, often used for small electornics, such as calculators."
|
||||
power_generated = 5
|
||||
//photovoltaic
|
||||
20
code/modules/integrated_electronics/time.dm
Normal file
20
code/modules/integrated_electronics/time.dm
Normal file
@@ -0,0 +1,20 @@
|
||||
/obj/item/integrated_circuit/time
|
||||
name = "time circuit"
|
||||
desc = "Now you can build your own clock!"
|
||||
complexity = 2
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 0
|
||||
|
||||
/obj/item/integrated_circuit/time/clock
|
||||
name = "integrated clock"
|
||||
desc = "Tells you what the local time is, specific to your station or planet."
|
||||
number_of_inputs = 0
|
||||
number_of_outputs = 6
|
||||
number_of_activators = 1
|
||||
name_of_outputs = list(
|
||||
"time (string)",
|
||||
"minute (string)",
|
||||
"hour (string)",
|
||||
"minute (number)",
|
||||
"hour (number)",
|
||||
)
|
||||
268
code/modules/integrated_electronics/tools.dm
Normal file
268
code/modules/integrated_electronics/tools.dm
Normal file
@@ -0,0 +1,268 @@
|
||||
/obj/item/device/integrated_electronics/debugger
|
||||
name = "debugger"
|
||||
desc = "This can be used to learn about, test, or find issues with your circuit designs."
|
||||
icon_state = "multitool"
|
||||
flags = CONDUCT
|
||||
w_class = 2
|
||||
var/datum/integrated_io/probe
|
||||
var/mode = "string"
|
||||
var/options = list("string", "number", "reference", "type", "null")
|
||||
|
||||
/obj/item/device/integrated_electronics/debugger/New()
|
||||
..()
|
||||
probe = new(src)
|
||||
|
||||
/obj/item/device/integrated_electronics/debugger/attack_self(mob/user)
|
||||
var/temporary_data = null
|
||||
var/choice = input(user, "Please select a data type to use as input.", "data type", "string") as null|anything in options
|
||||
if(choice)
|
||||
switch(choice)
|
||||
if("string")
|
||||
temporary_data = sanitize(input(user, "Please write something in text.", "string input") as null|text)
|
||||
if(istext(temporary_data))
|
||||
probe.data = temporary_data
|
||||
if("number")
|
||||
temporary_data = sanitize(input(user, "Please a number.", "number input") as null|num)
|
||||
if(isnum(temporary_data))
|
||||
probe.data = temporary_data
|
||||
if("reference")
|
||||
return
|
||||
if("type")
|
||||
return
|
||||
if("null")
|
||||
probe.data = null
|
||||
|
||||
/obj/item/device/integrated_electronics/proc/select_io(mob/user, var/obj/target)
|
||||
var/obj/item/integrated_circuit/selected_circuit = null
|
||||
if(!istype(/obj/item/integrated_circuit, target))
|
||||
var/list/possible_circuits = list()
|
||||
for(var/obj/item/integrated_circuit/IC in target)
|
||||
possible_circuits.Add(IC)
|
||||
if(possible_circuits.len)
|
||||
selected_circuit = input(user, "Choose the circuit you want to work on.", "Circuit Selection") as null|anything in possible_circuits
|
||||
else if(istype(/obj/item/integrated_circuit, target))
|
||||
selected_circuit = target
|
||||
|
||||
if(selected_circuit)
|
||||
var/list/possible_io = list()
|
||||
for(var/datum/integrated_io/I in selected_circuit.inputs)
|
||||
possible_io.Add(I)
|
||||
for(var/datum/integrated_io/O in selected_circuit.outputs)
|
||||
possible_io.Add(O)
|
||||
for(var/datum/integrated_io/A in selected_circuit.activators)
|
||||
possible_io.Add(A)
|
||||
if(possible_io.len)
|
||||
var/choice = input(user, "Choose the data channel you wish to select.", "Data Selection Selection") as null|anything in possible_io
|
||||
if(choice)
|
||||
return choice
|
||||
|
||||
#define WIRE "wire"
|
||||
#define WIRING "wiring"
|
||||
#define UNWIRE "unwire"
|
||||
#define UNWIRING "unwiring"
|
||||
|
||||
|
||||
/obj/item/device/integrated_electronics/wirer
|
||||
name = "data wirer"
|
||||
desc = "Used to connect various inputs and outputs together."
|
||||
icon_state = "multitool"
|
||||
flags = CONDUCT
|
||||
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/afterattack(atom/target, mob/user)
|
||||
if(isobj(target))
|
||||
if(mode == WIRE)
|
||||
selected_io = select_io(user, target)
|
||||
if(!selected_io)
|
||||
return
|
||||
user << "<span class='notice'>You attach a data wire to \the [target]'s [selected_io.name] data channel.</span>"
|
||||
mode = WIRING
|
||||
return
|
||||
|
||||
else if(mode == WIRING)
|
||||
var/datum/integrated_io/second_io = select_io(user, target)
|
||||
if(selected_io == second_io)
|
||||
user << "<span class='warning'>Wiring \the [target]'s [selected_io.name] into itself is rather pointless.<span>"
|
||||
return
|
||||
else if(second_io)
|
||||
if(second_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 [second_io.io_type].<span>"
|
||||
return
|
||||
|
||||
selected_io.linked |= second_io
|
||||
second_io.linked |= selected_io
|
||||
|
||||
// selected_io.linked = second_io
|
||||
// second_io.linked = selected_io
|
||||
user << "<span class='notice'>You connect \the [selected_io.holder]'s [selected_io.name] to \the [target]'s [second_io.name].</span>"
|
||||
mode = WIRE
|
||||
selected_io = null
|
||||
else if(mode == UNWIRE)
|
||||
selected_io = select_io(user, target)
|
||||
if(!selected_io)
|
||||
return
|
||||
if(!selected_io.linked.len)
|
||||
user << "<span class='warning'>There is nothing connected to \the [selected_io] data channel.</span>"
|
||||
return
|
||||
user << "<span class='notice'>You prepare to detach a data wire from \the [target]'s [selected_io.name] data channel.</span>"
|
||||
mode = UNWIRING
|
||||
return
|
||||
|
||||
else if(mode == UNWIRING)
|
||||
var/datum/integrated_io/second_io = select_io(user, target)
|
||||
if(selected_io == second_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>"
|
||||
return
|
||||
else if(second_io)
|
||||
if(selected_io in second_io.linked)
|
||||
second_io.linked.Remove(selected_io)
|
||||
selected_io.linked.Remove(second_io)
|
||||
user << "<span class='notice'>You disconnect \the [selected_io.holder]'s [selected_io.name] from \
|
||||
\the [second_io.holder]'s [second_io.name].</span>"
|
||||
else
|
||||
user << "<span class='warning'>\The [selected_io.holder]'s [selected_io.name] and \the [second_io.holder]'s \
|
||||
[second_io.name] are not connected.<span>"
|
||||
return
|
||||
/*
|
||||
var/datum/integrated_io/third_io = select_io(user, second_io.linked)
|
||||
if(third_io && selected_io in third_io.linked)
|
||||
third_io.linked.Remove(selected_io)
|
||||
selected_io.linked.Remove(second_io)
|
||||
*/
|
||||
mode = UNWIRE
|
||||
return
|
||||
/*
|
||||
var/datum/integrated_io/target_io = select_io(user, target)
|
||||
if(target_io && target_io.linked)
|
||||
user << "<span class='notice'>You disconnect \the [target_io.holder]'s [target_io.name] \
|
||||
from \the [target_io.linked.holder]'s [target_io.linked.linked].<span>"
|
||||
if(target_io.linked.linked && target_io.linked.linked == target_io)
|
||||
target_io.linked.linked = null
|
||||
target_io.linked = null
|
||||
*/
|
||||
/obj/item/device/integrated_electronics/wirer/attack_self(mob/user)
|
||||
switch(mode)
|
||||
if(WIRE)
|
||||
mode = UNWIRE
|
||||
if(WIRING)
|
||||
if(selected_io)
|
||||
user << "<span class='notice'>You decide not to wire the data channel.</span>"
|
||||
selected_io = null
|
||||
mode = UNWIRE
|
||||
if(UNWIRE)
|
||||
mode = WIRE
|
||||
user << "<span class='notice'>You set \the [src] to [mode].<span>"
|
||||
|
||||
#undef WIRE
|
||||
#undef WIRING
|
||||
#undef UNWIRE
|
||||
#undef UNWIRING
|
||||
|
||||
/obj/item/weapon/storage/bag/circuits
|
||||
name = "circuit satchel"
|
||||
desc = "This bag's essential for any circuitry projects."
|
||||
icon = 'icons/obj/mining.dmi'
|
||||
icon_state = "satchel"
|
||||
slot_flags = SLOT_BELT | SLOT_POCKET
|
||||
w_class = 2
|
||||
storage_slots = 200
|
||||
max_storage_space = 400
|
||||
max_w_class = 3
|
||||
display_contents_with_number = 1
|
||||
can_hold = list(/obj/item/integrated_circuit)
|
||||
|
||||
/obj/item/weapon/storage/bag/circuits/pre_filled/New()
|
||||
..()
|
||||
var/i = 10
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/arithmetic/addition(src)
|
||||
i--
|
||||
i = 10
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/arithmetic/subtraction(src)
|
||||
i--
|
||||
i = 10
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/arithmetic/multiplication(src)
|
||||
i--
|
||||
i = 10
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/arithmetic/division(src)
|
||||
i--
|
||||
i = 5
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/arithmetic/absolute(src)
|
||||
i--
|
||||
i = 5
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/arithmetic/average(src)
|
||||
i--
|
||||
i = 10
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/logic/equals(src)
|
||||
i--
|
||||
i = 10
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/logic/less_than(src)
|
||||
i--
|
||||
i = 10
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/logic/less_than_or_equal(src)
|
||||
i--
|
||||
i = 10
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/logic/greater_than(src)
|
||||
i--
|
||||
i = 10
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/logic/greater_than_or_equal(src)
|
||||
i--
|
||||
i = 10
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/logic/not(src)
|
||||
i--
|
||||
i = 10
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/memory(src)
|
||||
i--
|
||||
i = 5
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/memory/medium(src)
|
||||
i--
|
||||
i = 5
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/memory/large(src)
|
||||
i--
|
||||
i = 5
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/memory/huge(src)
|
||||
i--
|
||||
i = 5
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/input/numberpad(src)
|
||||
i--
|
||||
i = 5
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/input/button(src)
|
||||
i--
|
||||
i = 5
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/output/screen(src)
|
||||
i--
|
||||
i = 5
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/transfer/splitter(src)
|
||||
i--
|
||||
i = 5
|
||||
while(i)
|
||||
new /obj/item/integrated_circuit/transfer/activator_splitter(src)
|
||||
i--
|
||||
new /obj/item/device/electronic_assembly(src)
|
||||
new /obj/item/device/integrated_electronics/wirer(src)
|
||||
Reference in New Issue
Block a user