mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 19:22:56 +00:00
Circuit iterator ++ and --
Self modifiyng circuits that add or subtact 1 form their own internal memory. This should simplify multiplexing
This commit is contained in:
@@ -312,3 +312,34 @@
|
|||||||
push_data()
|
push_data()
|
||||||
activate_pin(2)
|
activate_pin(2)
|
||||||
|
|
||||||
|
//CHOMPADDITION Math iterators
|
||||||
|
/obj/item/integrated_circuit/arithmetic/iterator
|
||||||
|
name = "++"
|
||||||
|
desc = "This circuit adds 1 to its input."
|
||||||
|
extended_desc = "This circuit is equal to an operation performing X++."
|
||||||
|
icon_state = "addition"
|
||||||
|
inputs = list("input" = IC_PINTYPE_NUMBER)
|
||||||
|
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
|
||||||
|
complexity = 1
|
||||||
|
power_draw_per_use = 1 // one of the most basic operators there is.
|
||||||
|
var/i = 1
|
||||||
|
|
||||||
|
/obj/item/integrated_circuit/arithmetic/iterator/invert
|
||||||
|
name = "--"
|
||||||
|
desc = "This circuit subtracts 1 to its input."
|
||||||
|
extended_desc = "This circuit is equal to an operation performing X--."
|
||||||
|
icon_state = "subtraction"
|
||||||
|
i = -1
|
||||||
|
|
||||||
|
/obj/item/integrated_circuit/arithmetic/iterator/do_work()
|
||||||
|
var/result = null
|
||||||
|
pull_data()
|
||||||
|
var/incoming = get_pin_data(IC_INPUT, 1)
|
||||||
|
if(!isnull(incoming))
|
||||||
|
result = result + i
|
||||||
|
else if(!incoming)
|
||||||
|
result = result
|
||||||
|
|
||||||
|
set_pin_data(IC_INPUT, 1, result)
|
||||||
|
push_data()
|
||||||
|
activate_pin(2)
|
||||||
|
|||||||
Reference in New Issue
Block a user