mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-15 04:01:41 +00:00
* Circuit component descriptions and module names are now visible to the naked eye. (#60545) * Circuit component descriptions and module names are now visible to the naked eye. Co-authored-by: Gurkenglas <gurkenglas@hotmail.de>
39 lines
1.0 KiB
Plaintext
39 lines
1.0 KiB
Plaintext
/**
|
|
* # Delay Component
|
|
*
|
|
* Delays a signal by a specified duration.
|
|
*/
|
|
/obj/item/circuit_component/delay
|
|
display_name = "Delay"
|
|
desc = "A component that delays a signal by a specified duration."
|
|
|
|
/// Amount to delay by
|
|
var/datum/port/input/delay_amount
|
|
/// Input signal to fire the delay
|
|
var/datum/port/input/trigger
|
|
|
|
/// The output of the signal
|
|
var/datum/port/output/output
|
|
|
|
/obj/item/circuit_component/delay/Initialize()
|
|
. = ..()
|
|
delay_amount = add_input_port("Delay", PORT_TYPE_NUMBER, FALSE)
|
|
trigger = add_input_port("Trigger", PORT_TYPE_SIGNAL)
|
|
|
|
output = add_output_port("Result", PORT_TYPE_SIGNAL)
|
|
|
|
/obj/item/circuit_component/delay/input_received(datum/port/input/port)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
|
|
if(!COMPONENT_TRIGGERED_BY(trigger, port))
|
|
return
|
|
|
|
var/delay = delay_amount.input_value
|
|
if(delay > COMP_DELAY_MIN_VALUE)
|
|
// Convert delay into deciseconds
|
|
addtimer(CALLBACK(output, /datum/port/output.proc/set_output, trigger.input_value), delay*10)
|
|
else
|
|
output.set_output(trigger.input_value)
|