From 82a513d8cf9153e06b42c31e999840cf7f15eb4e Mon Sep 17 00:00:00 2001 From: Sharkmare <34294231+Sharkmare@users.noreply.github.com> Date: Thu, 2 Mar 2023 14:19:06 +0100 Subject: [PATCH] Circuit iterator ++ and -- Self modifiyng circuits that add or subtact 1 form their own internal memory. This should simplify multiplexing --- .../subtypes/arithmetic.dm | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/code/modules/integrated_electronics/subtypes/arithmetic.dm b/code/modules/integrated_electronics/subtypes/arithmetic.dm index 192d317baf..bbcc6332f7 100644 --- a/code/modules/integrated_electronics/subtypes/arithmetic.dm +++ b/code/modules/integrated_electronics/subtypes/arithmetic.dm @@ -312,3 +312,34 @@ push_data() 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)