From 36212e59e19576da1f82540ff443542b2e253f69 Mon Sep 17 00:00:00 2001 From: CRITAWAKETS Date: Thu, 28 Nov 2024 22:28:18 -0500 Subject: [PATCH] Adds in the modulo operator to the circuit arithmetic component. (#88253) ## About The Pull Request ![image](https://github.com/user-attachments/assets/17a5d230-c10f-4fda-b782-0d59c2797bff) This PR just adds in modulo to the circuit arithmetic component. ## Why It's Good For The Game You _can_ calculate it yourself, but then it ends up extremely unoptimal and you're usually better off not doing it. It also ends up really hard to read. I want to see more clever circuits and computing things. ## Changelog :cl: add: Added in the modulo operator to the circuit arithmetic component. /:cl: --- code/modules/wiremod/components/math/arithmetic.dm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/modules/wiremod/components/math/arithmetic.dm b/code/modules/wiremod/components/math/arithmetic.dm index 083616f1e0e..20474ec9492 100644 --- a/code/modules/wiremod/components/math/arithmetic.dm +++ b/code/modules/wiremod/components/math/arithmetic.dm @@ -2,6 +2,7 @@ #define COMP_ARITHMETIC_SUBTRACT "Subtract" #define COMP_ARITHMETIC_MULTIPLY "Multiply" #define COMP_ARITHMETIC_DIVIDE "Divide" +#define COMP_ARITHMETIC_MODULO "Modulo" #define COMP_ARITHMETIC_MIN "Minimum" #define COMP_ARITHMETIC_MAX "Maximum" @@ -34,6 +35,7 @@ COMP_ARITHMETIC_SUBTRACT, COMP_ARITHMETIC_MULTIPLY, COMP_ARITHMETIC_DIVIDE, + COMP_ARITHMETIC_MODULO, COMP_ARITHMETIC_MIN, COMP_ARITHMETIC_MAX, ) @@ -75,6 +77,8 @@ result = null break result /= value + if(COMP_ARITHMETIC_MODULO) + result %= value if(COMP_ARITHMETIC_MAX) result = max(result, value) if(COMP_ARITHMETIC_MIN) @@ -86,5 +90,6 @@ #undef COMP_ARITHMETIC_SUBTRACT #undef COMP_ARITHMETIC_MULTIPLY #undef COMP_ARITHMETIC_DIVIDE +#undef COMP_ARITHMETIC_MODULO #undef COMP_ARITHMETIC_MIN #undef COMP_ARITHMETIC_MAX