Posted 01 June 2015 - 02:33 PM
As I understand it, the code below searches in a table for an item called, "1*item.itemCellUranDepleted@0" and then turns the function "hasEmptyCell()" to true. My question is, how do I search for all items that start with "1*item.itemCellUranDepleted@" and still make the function true?
For example "1*item.itemCellUranDepleted@1231231", "1*item.itemCellUranDepleted@2342", etc. would all make the function true not just "1*item.itemCellUranDepleted@0"
For example "1*item.itemCellUranDepleted@1231231", "1*item.itemCellUranDepleted@2342", etc. would all make the function true not just "1*item.itemCellUranDepleted@0"
os.loadAPI("/rom/apis/sensors")
while true do
local function hasEmptyCell()
local controllerSide, sensor, probes = sensors.getController(), "Sensor", "InventoryContent"
for _, target in pairs( sensors.getAvailableTargetsforProbe( controllerSide, sensor, probes ) ) do
local data = sensors.getSensorReadingAsDict( controllerSide, sensor, "Nuclear Reactor,-426,64,-715", probes )
for i=1, table.maxn(data) do
if data[i] == "1*item.itemCellUranDepleted@0" then
return true
end
end
end
return false
end
if hasEmptyCell() then found = true else found = false end
print( found )
if found == true then
rs.setOutput("front", false) else
rs.setOutput("front", true)
end
sleep(1)
end