/
Lachklen
/
MYtgstation
Обзор
Документация
Войти
/
Lachklen
/
MYtgstation
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
code/modules/wiremod/components/math/random.dm
36 строк
1010 B
Watermelon914
Integrated the component printer into the integrated circuit UI. You can now link integrated circuits to component printers (#62287)
28 окт 2021, 21:42
Не верифицирован
28 окт 2021, 21:42
44a2af7
Код
Авторство
О чём код?
/** * # Random Component * * Generates a random number between specific values */ /obj/item/circuit_component/random display_name = "Random" desc = "A component that returns random values." category = "Math" /// The minimum value that the random number can be var/datum/port/input/minimum /// The maximum value that the random number can be var/datum/port/input/maximum circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL /// The result from the output var/datum/port/output/output /obj/item/circuit_component/random/populate_ports() minimum = add_input_port("Minimum", PORT_TYPE_NUMBER, trigger = null) maximum = add_input_port("Maximum", PORT_TYPE_NUMBER, trigger = null) output = add_output_port("Output", PORT_TYPE_NUMBER) /obj/item/circuit_component/random/input_received(datum/port/input/port) var/min_val = minimum.value || 0 var/max_val = maximum.value || 0 if(max_val < min_val) output.set_output(0) return output.set_output(rand(min_val, max_val))