Fixes some circuit bugs.

This commit is contained in:
Neerti
2019-01-27 00:47:37 -05:00
committed by VirgoBot
parent 30ab44613d
commit 81101d30da
5 changed files with 59 additions and 84 deletions

View File

@@ -339,7 +339,7 @@
if(battery) if(battery)
var/lost = battery.use(amount * CELLRATE) var/lost = battery.use(amount * CELLRATE)
net_power -= lost net_power -= lost
return TRUE return lost > 0
return FALSE return FALSE
// Ditto for giving. // Ditto for giving.

View File

@@ -57,7 +57,7 @@
desc = "A complicated piece of technology which converts bodily nutriments of a host into electricity." desc = "A complicated piece of technology which converts bodily nutriments of a host into electricity."
extended_desc = "The siphon generates 10W of energy, so long as the siphon exists inside a biological entity. The entity will feel an increased \ extended_desc = "The siphon generates 10W of energy, so long as the siphon exists inside a biological entity. The entity will feel an increased \
appetite and will need to eat more often due to this. This device will fail if used inside synthetic entities." appetite and will need to eat more often due to this. This device will fail if used inside synthetic entities."
icon_state = "setup_implant" icon_state = "implant_power"
complexity = 10 complexity = 10
origin_tech = list(TECH_POWER = 4, TECH_ENGINEERING = 4, TECH_DATA = 4, TECH_BIO = 5) origin_tech = list(TECH_POWER = 4, TECH_ENGINEERING = 4, TECH_DATA = 4, TECH_BIO = 5)
spawn_flags = IC_SPAWN_RESEARCH spawn_flags = IC_SPAWN_RESEARCH
@@ -82,8 +82,6 @@
desc = "A small circuit designed to be connected to an internal power wire inside a synthetic entity." desc = "A small circuit designed to be connected to an internal power wire inside a synthetic entity."
extended_desc = "The siphon generates 10W of energy, so long as the siphon exists inside a synthetic entity. The entity need to recharge \ extended_desc = "The siphon generates 10W of energy, so long as the siphon exists inside a synthetic entity. The entity need to recharge \
more often due to this. This device will fail if used inside organic entities." more often due to this. This device will fail if used inside organic entities."
icon_state = "setup_implant"
complexity = 10
origin_tech = list(TECH_POWER = 3, TECH_ENGINEERING = 4, TECH_DATA = 3) origin_tech = list(TECH_POWER = 3, TECH_ENGINEERING = 4, TECH_DATA = 3)
spawn_flags = IC_SPAWN_RESEARCH spawn_flags = IC_SPAWN_RESEARCH

View File

@@ -4,12 +4,14 @@
/obj/item/integrated_circuit/output/screen /obj/item/integrated_circuit/output/screen
name = "small screen" name = "small screen"
desc = "This small screen can display a single piece of data, when the machine is examined closely." desc = "This small screen can display a single piece of data, when the machine is examined closely."
extended_desc = "This will show the data loaded into it when the machine is examined."
icon_state = "screen" icon_state = "screen"
inputs = list("displayed data" = IC_PINTYPE_ANY) inputs = list("displayed data" = IC_PINTYPE_ANY)
outputs = list() outputs = list()
activators = list("load data" = IC_PINTYPE_PULSE_IN) activators = list("load data" = IC_PINTYPE_PULSE_IN)
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
power_draw_per_use = 10 power_draw_per_use = 10
cooldown_per_use = 0 // Can be updated frequently.
var/stuff_to_display = null var/stuff_to_display = null
@@ -30,8 +32,9 @@
stuff_to_display = I.data stuff_to_display = I.data
/obj/item/integrated_circuit/output/screen/medium /obj/item/integrated_circuit/output/screen/medium
name = "screen" name = "medium screen"
desc = "This screen allows for people holding the device to see a piece of data." desc = "This screen allows for people holding the device to see a piece of data."
extended_desc = "This will display a message to the user holding the assembly when activated."
icon_state = "screen_medium" icon_state = "screen_medium"
power_draw_per_use = 20 power_draw_per_use = 20
@@ -45,8 +48,10 @@
/obj/item/integrated_circuit/output/screen/large /obj/item/integrated_circuit/output/screen/large
name = "large screen" name = "large screen"
desc = "This screen allows for people able to see the device to see a piece of data." desc = "This screen allows for people able to see the device to see a piece of data."
extended_desc = "This will display a message to everyone who can see the assembly when activated."
icon_state = "screen_large" icon_state = "screen_large"
power_draw_per_use = 40 power_draw_per_use = 40
cooldown_per_use = 1 SECOND // Because everyone will get the output instead of just the user/examiner.
/obj/item/integrated_circuit/output/screen/large/do_work() /obj/item/integrated_circuit/output/screen/large/do_work()
..() ..()
@@ -114,8 +119,8 @@
/obj/item/integrated_circuit/output/text_to_speech /obj/item/integrated_circuit/output/text_to_speech
name = "text-to-speech circuit" name = "text-to-speech circuit"
desc = "A miniature speaker is attached to this component." desc = "A miniature speaker is attached to this component. It is able to transpose any valid text to speech."
extended_desc = "This unit is more advanced than the plain speaker circuit, able to transpose any valid text to speech." extended_desc = "This will emit an audible message to anyone who can hear the assembly."
icon_state = "speaker" icon_state = "speaker"
complexity = 12 complexity = 12
cooldown_per_use = 4 SECONDS cooldown_per_use = 4 SECONDS

View File

@@ -7,79 +7,38 @@
category_text = "Time" category_text = "Time"
/obj/item/integrated_circuit/time/delay /obj/item/integrated_circuit/time/delay
name = "two-sec delay circuit" name = "delay circuit"
desc = "This sends a pulse signal out after a delay, critical for ensuring proper control flow in a complex machine. \ desc = "This sends a pulse signal out after a delay defined in tenths of a second, critical for ensuring proper \
This circuit is set to send a pulse after a delay of two seconds." control flow in a complex machine. This circuit's delay can be customized, between 1/10th of a second to one hour. \
icon_state = "delay-20" The delay is updated upon receiving a pulse."
var/delay = 2 SECONDS extended_desc = "The delay is defined in tenths of a second. For instance, 4 will be a delay of 0.4 seconds, or 15 for 1.5 seconds."
icon_state = "delay"
inputs = list("delay time" = IC_PINTYPE_NUMBER)
activators = list("incoming"= IC_PINTYPE_PULSE_IN,"outgoing" = IC_PINTYPE_PULSE_OUT) activators = list("incoming"= IC_PINTYPE_PULSE_IN,"outgoing" = IC_PINTYPE_PULSE_OUT)
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
power_draw_per_use = 2 power_draw_per_use = 2
var/delay = 20
/obj/item/integrated_circuit/time/delay/do_work() /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
sleep(delay)
activate_pin(2)
/obj/item/integrated_circuit/time/delay/five_sec
name = "five-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 five seconds."
icon_state = "delay-50"
delay = 5 SECONDS
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
/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 = 1 SECOND
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
/obj/item/integrated_circuit/time/delay/half_sec
name = "half-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 half a second."
icon_state = "delay-5"
delay = 5
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
/obj/item/integrated_circuit/time/delay/tenth_sec
name = "tenth-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 1/10th of a second."
icon_state = "delay-1"
delay = 1
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
/obj/item/integrated_circuit/time/delay/custom
name = "custom delay circuit"
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"
inputs = list("delay time" = IC_PINTYPE_NUMBER)
spawn_flags = IC_SPAWN_RESEARCH
/obj/item/integrated_circuit/time/delay/custom/do_work()
var/delay_input = get_pin_data(IC_INPUT, 1) var/delay_input = get_pin_data(IC_INPUT, 1)
if(delay_input && isnum(delay_input) ) if(delay_input && isnum(delay_input) )
var/new_delay = between(1, delay_input, 36000) //An hour. var/new_delay = CLAMP(delay_input, 1, 1 HOUR)
delay = new_delay delay = new_delay
..() addtimer(CALLBACK(src, .proc/activate_pin, 2), delay)
/obj/item/integrated_circuit/time/ticker /obj/item/integrated_circuit/time/ticker
name = "ticker circuit" name = "ticker circuit"
desc = "This circuit sends an automatic pulse every four seconds." desc = "This circuit sends an automatic pulse every given interval, defined in tenths of a second."
icon_state = "tick-m" extended_desc ="This circuit sends an automatic pulse every given interval, defined in tenths of a second. \
complexity = 8 For example, setting the time pin to 4 will send a pulse every 0.4 seconds, or 15 for every 1.5 seconds.<br>\
var/ticks_to_pulse = 4 The power consumption will scale based on how fast this ticks. Also, note that most components have a short \
var/ticks_completed = 0 internal cooldown when activated."
var/is_running = FALSE icon_state = "tick-f"
inputs = list("enable ticking" = IC_PINTYPE_BOOLEAN) complexity = 10
inputs = list("enable ticking" = IC_PINTYPE_BOOLEAN, "delay time" = IC_PINTYPE_NUMBER)
activators = list("outgoing pulse" = IC_PINTYPE_PULSE_OUT) activators = list("outgoing pulse" = IC_PINTYPE_PULSE_OUT)
<<<<<<< HEAD
spawn_flags = IC_SPAWN_RESEARCH spawn_flags = IC_SPAWN_RESEARCH
power_draw_per_use = 4 power_draw_per_use = 4
@@ -87,11 +46,29 @@
if(is_running) if(is_running)
processing_objects -= src processing_objects -= src
. = ..() . = ..()
=======
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
power_draw_per_use = 5
var/delay = 2 SECONDS
var/next_fire = 0
var/is_running = FALSE
// Power consumption scales based on how fast it ticks.
// This, plus the fact it ticks more often will increase consumption non-linearly,
// and the circuit cooldown and will hopefully discourage stupidly fast ticking machines.
var/max_power_draw = 500
>>>>>>> dcc6cad... Fixes some circuit bugs. (#5897)
/obj/item/integrated_circuit/time/ticker/on_data_written() /obj/item/integrated_circuit/time/ticker/on_data_written()
var/delay_input = get_pin_data(IC_INPUT, 2)
if(delay_input && isnum(delay_input) )
var/new_delay = CLAMP(delay_input, 1, 1 HOUR)
delay = new_delay
power_draw_per_use = CEILING((max_power_draw / delay) / delay, 1)
var/do_tick = get_pin_data(IC_INPUT, 1) var/do_tick = get_pin_data(IC_INPUT, 1)
if(do_tick && !is_running) if(do_tick && !is_running)
is_running = TRUE is_running = TRUE
<<<<<<< HEAD
processing_objects |= src processing_objects |= src
else if(is_running) else if(is_running)
is_running = FALSE is_running = FALSE
@@ -107,24 +84,19 @@
else else
ticks_completed = 0 ticks_completed = 0
activate_pin(1) activate_pin(1)
=======
tick()
else if(!do_tick && is_running)
is_running = FALSE
>>>>>>> dcc6cad... Fixes some circuit bugs. (#5897)
/obj/item/integrated_circuit/time/ticker/fast
name = "fast ticker"
desc = "This advanced circuit sends an automatic pulse every two seconds."
icon_state = "tick-f"
complexity = 12
ticks_to_pulse = 2
spawn_flags = IC_SPAWN_RESEARCH
power_draw_per_use = 8
/obj/item/integrated_circuit/time/ticker/slow /obj/item/integrated_circuit/time/ticker/proc/tick()
name = "slow ticker" if(is_running && check_power())
desc = "This simple circuit sends an automatic pulse every six seconds." addtimer(CALLBACK(src, .proc/tick), delay)
icon_state = "tick-s" if(world.time > next_fire)
complexity = 4 next_fire = world.time + delay
ticks_to_pulse = 6 activate_pin(1)
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
power_draw_per_use = 2
/obj/item/integrated_circuit/time/clock /obj/item/integrated_circuit/time/clock
name = "integrated clock" name = "integrated clock"
@@ -148,4 +120,4 @@
set_pin_data(IC_OUTPUT, 4, text2num(time2text(station_time_in_ticks, "ss") ) ) set_pin_data(IC_OUTPUT, 4, text2num(time2text(station_time_in_ticks, "ss") ) )
push_data() push_data()
activate_pin(2) activate_pin(2)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB