mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-21 21:17:44 +01:00
Added max and min circuit (#39013)
* Added max and min circuit This now has a max and min circuit which checks all values and returns the highest/lowest of them. Tested and working. * update: saving lines of code The more compact min max. you may as well want to try the same with addition and substraction. * Reformated code and improved proc As you said, added early continue, put the vars low and changed the logic on the result. * Update arithmetic.dm
This commit is contained in:
@@ -311,3 +311,33 @@
|
||||
set_pin_data(IC_OUTPUT, 1, result)
|
||||
push_data()
|
||||
activate_pin(2)
|
||||
|
||||
// -Max- //
|
||||
/obj/item/integrated_circuit/arithmetic/max
|
||||
name = "max circuit"
|
||||
desc = "This circuit sends out the highest number."
|
||||
extended_desc = "The highest number is put out. Null is ignored."
|
||||
icon_state = "addition"
|
||||
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
|
||||
var/min_comparision = FALSE
|
||||
|
||||
/obj/item/integrated_circuit/arithmetic/max/do_work()
|
||||
var/result
|
||||
for(var/k in 1 to inputs.len)
|
||||
var/I = get_pin_data(IC_INPUT, k)
|
||||
if(!isnum(I))
|
||||
continue
|
||||
if(!isnum(result) || (!min_comparision && I > result) || (min_comparision && I < result))
|
||||
result = I
|
||||
if(!isnum(result))
|
||||
result = 0
|
||||
set_pin_data(IC_OUTPUT, 1, result)
|
||||
push_data()
|
||||
activate_pin(2)
|
||||
|
||||
// -Min- //
|
||||
/obj/item/integrated_circuit/arithmetic/max/min
|
||||
name = "min circuit"
|
||||
desc = "This circuit sends out the smallest number."
|
||||
extended_desc = "The smallest number is put out. Null is ignored. In case no number is found, 0 is given out."
|
||||
min_comparision = TRUE
|
||||
|
||||
Reference in New Issue
Block a user