[Feature] Method `getRadiationRaw` for Environment Sensor
Peekofwar opened this issue ยท 3 comments
Something I encountered while programming a radiation detection system that would print out the max radiation detected from a network of sensors was that I can't necessarily predict if "nSv" and "mSv" are the only units of measurement. It would be far more useful to just receive one unit of measurement that can easily be compared.
This untested broken function is what I ended up with when attempting to grab the current radiation level from a network of sensors:
getRad = function()
local radiationTable = {}
local p = false
for i=1, #equipment.radiationSensors do
if peripheral.isPresent(equipment.radiationSensors[i]) then
p = equipment.radiationSensors.getRadiation()
if p.unit ~= "nSv" then
table.insert(radiationTable,p.radiation)
end
end
end
if #radiationTable > 0 then
return {true, math.max(table.unpack(radiationTable)), p.unit}
else
for i=1, #equipment.radiationSensors do
if peripheral.isPresent(equipment.radiationSensors[i]) then
p = equipment.radiationSensors.getRadiation()
if p.unit == "nSv" then
table.insert(radiationTable,p.radiation)
end
end
end
return {false, math.max(table.unpack(radiationTable)), p.unit}
end
end,end
end
return false, math.max(table.unpack(radiationTable)), p.unit
end
end,
Something that would be a lot easier to code would be:
getRad = function()
local radiationTable = {}
for i=1, #equipment.radiationSensors do
table.insert(radiationTable,equipment.radiationSensors[i].getRadiationRaw())
end
return math.max(table.unpack(radiationTable))
end