Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes computer console circuits more consistent #83412

Merged
merged 8 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion code/modules/modular_computers/computers/item/computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,10 @@
playsound(src, 'sound/machines/card_slide.ogg', 50)

/obj/item/modular_computer/proc/turn_on(mob/user, open_ui = TRUE)
var/issynth = HAS_SILICON_ACCESS(user) // Robots and AIs get different activation messages.
var/issynth = FALSE // Robots and AIs get different activation messages.
if(user)
issynth = HAS_SILICON_ACCESS(user)

if(atom_integrity <= integrity_failure * max_integrity)
if(user)
if(issynth)
Expand Down
58 changes: 27 additions & 31 deletions code/modules/modular_computers/computers/item/computer_circuit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
var/obj/item/modular_computer/computer
///Turns the PC on/off
var/datum/port/input/on_off
///When set, will print a piece of paper with the value as text.
///Determines the text to be printed
var/datum/port/input/print_text
/// Print when triggered
var/datum/port/input/print

///Sent when turned on
Expand All @@ -18,6 +20,7 @@
var/datum/port/input/red
var/datum/port/input/green
var/datum/port/input/blue
var/datum/port/input/set_color

/obj/item/circuit_component/modpc/register_shell(atom/movable/shell)
. = ..()
Expand All @@ -39,10 +42,11 @@
* I hope you're cool with me doing it here.
*/
if(computer.has_light && isnull(lights))
lights = add_input_port("Toggle Lights", PORT_TYPE_SIGNAL)
lights = add_input_port("Toggle Lights", PORT_TYPE_SIGNAL, trigger = PROC_REF(toggle_flashlight))
red = add_input_port("Red", PORT_TYPE_NUMBER)
green = add_input_port("Green", PORT_TYPE_NUMBER)
blue = add_input_port("Blue", PORT_TYPE_NUMBER)
set_color = add_input_port("Set Color", PORT_TYPE_SIGNAL, trigger = PROC_REF(set_flashlight_color))

/obj/item/circuit_component/modpc/unregister_shell(atom/movable/shell)
if(computer)
Expand All @@ -51,45 +55,37 @@
return ..()

/obj/item/circuit_component/modpc/populate_ports()
on_off = add_input_port("Turn On/Off", PORT_TYPE_SIGNAL)
print = add_input_port("Print Text", PORT_TYPE_STRING)
on_off = add_input_port("Turn On/Off", PORT_TYPE_SIGNAL, trigger = PROC_REF(toggle_power))
print_text = add_input_port("Print Text", PORT_TYPE_STRING)
print = add_input_port("Print", PORT_TYPE_SIGNAL, trigger = PROC_REF(print_text))

is_on = add_output_port("Turned On", PORT_TYPE_SIGNAL)
is_on = add_output_port("Shut Down", PORT_TYPE_SIGNAL)
is_off = add_output_port("Shut Down", PORT_TYPE_SIGNAL)

/obj/item/circuit_component/modpc/pre_input_received(datum/port/input/port)
if(isnull(computer))
return
if(COMPONENT_TRIGGERED_BY(print, port))
if(COMPONENT_TRIGGERED_BY(print_text, port))
print.set_value(html_encode(trim(print.value, MAX_PAPER_LENGTH)))
else if(COMPONENT_TRIGGERED_BY(red, port))
red.set_value(clamp(red.value, 0, 255))
else if(COMPONENT_TRIGGERED_BY(blue, port))
blue.set_value(clamp(blue.value, 0, 255))
else if(COMPONENT_TRIGGERED_BY(green, port))
green.set_value(clamp(green.value, 0, 255))

/obj/item/circuit_component/modpc/input_received(datum/port/input/port)
if(isnull(computer))
return
if(COMPONENT_TRIGGERED_BY(on_off, port))
if(computer.enabled)
INVOKE_ASYNC(computer, TYPE_PROC_REF(/obj/item/modular_computer, shutdown_computer))
else
INVOKE_ASYNC(computer, TYPE_PROC_REF(/obj/item/modular_computer, turn_on))
return

if(!computer.enabled)
return
/obj/item/circuit_component/modpc/proc/print_text(datum/source)
if(computer.enabled)
computer.print_text(print_text.value)

/obj/item/circuit_component/modpc/proc/toggle_power(datum/source)
if(computer.enabled)
INVOKE_ASYNC(computer, TYPE_PROC_REF(/obj/item/modular_computer, shutdown_computer))
else
INVOKE_ASYNC(computer, TYPE_PROC_REF(/obj/item/modular_computer, turn_on))

if(COMPONENT_TRIGGERED_BY(print, port))
computer.print_text(print.value)
/obj/item/circuit_component/modpc/proc/toggle_flashlight(datum/source)
computer.toggle_flashlight()

if(lights)
if(COMPONENT_TRIGGERED_BY(lights, port))
computer.toggle_flashlight()
if(COMPONENT_TRIGGERED_BY(red, port) || COMPONENT_TRIGGERED_BY(green, port) || COMPONENT_TRIGGERED_BY(blue, port))
computer.set_flashlight_color(rgb(red.value || 0, green.value || 0, blue.value || 0))
/obj/item/circuit_component/modpc/proc/set_flashlight_color(datum/source)
red.set_value(clamp(red.value, 0, 255))
blue.set_value(clamp(blue.value, 0, 255))
green.set_value(clamp(green.value, 0, 255))
computer.set_flashlight_color(rgb(red.value || 0, green.value || 0, blue.value || 0))

/obj/item/circuit_component/modpc/proc/computer_on(datum/source, mob/user)
SIGNAL_HANDLER
Expand Down
Loading