[MIRROR] Changes reagentscanner circuit component to use Table [MDB IGNORE] (#16145)

* Changes reagentscanner circuit component to use Table (#69745)

Changes components\atom\reagentscanner to use table list from Assoc list.
Added purity output to components\atom\reagentscanner.
At time of making this its impossible to iterate through the output of reagentscanner via loops or numerical index and to determine the amount or the reagent scanned you needed to know its associated value which is less than idea.

Queried this issue on coderbus meeting 3 then asked Watermelon and he agreed that a change would be good.

Added a "purity" to the table outputs to make shells of this component "desirable" to chemistry who need to use Ph_meter to check exact purity. If this not allowed I’m willing to make an \atom\reagentscanner\adv variant that will comparable to Ph_meter.

I intend to give the same treatment to materialscanner.

* Changes reagentscanner circuit component to use Table

Co-authored-by: Dmeto <75919495+Dmeto@users.noreply.github.com>
This commit is contained in:
SkyratBot
2022-09-11 17:11:15 +02:00
committed by GitHub
parent 1ed9270c60
commit cfe169d1de
@@ -20,10 +20,14 @@
/obj/item/circuit_component/reagentscanner/get_ui_notices()
. = ..()
. += create_ui_notice("Maximum Range: [max_range] tiles", "orange", "info")
. += create_table_notices(list(
"reagent",
"volume",
))
/obj/item/circuit_component/reagentscanner/populate_ports()
input_port = add_input_port("Entity", PORT_TYPE_ATOM)
result = add_output_port("Reagents", PORT_TYPE_ASSOC_LIST(PORT_TYPE_STRING, PORT_TYPE_NUMBER))
result = add_output_port("Reagents", PORT_TYPE_TABLE)
/obj/item/circuit_component/reagentscanner/input_received(datum/port/input/port)
var/atom/entity = input_port.value
@@ -31,7 +35,10 @@
if(!istype(entity) || !IN_GIVEN_RANGE(location, entity, max_range))
result.set_output(null)
return
var/list/output_list = list()
var/list/new_table = list()
for(var/datum/reagent/reagent as anything in entity.reagents?.reagent_list)
output_list[reagent.name] += reagent.volume
result.set_output(output_list)
var/list/entry = list()
entry["reagent"] = reagent.name
entry["volume"] = reagent.volume
new_table += list(entry)
result.set_output(new_table)