I am using Technic SSP and am trying to make a program that I can customize as the need asrises for different things but for right now I am in need of the program to be able to get the contents of the chest that I have set up for my Quarry to dump its resources into and then tell me what items are in there. I do not however want the standard item designation but rather a more simpliflied one.
Example.
Standard Designation: item.emerald@0
Simplified Output: Diamond
I have already been able to get the basics done with respect to normal items that have a @0 but anything that uses @1 or more I can not get the program to realize that this is a different Item. It will still count it as the @0 item.
Example.
Standard Designation ——- Simplified Output ——— Amount
item.tcicrystals@0 Vis Crystals 4
item.tcicrystals@1 Vaporous crystals 0
The program is not meant to output the Standard Designation at all but only the Simplified Designation and the amount of that item in the chest. and it auto updates every second.
It does work however, Even though I have 1 Vis Crystal, 1 Vaporous Crystal, 1 Firey Crystal, and 1 Tainted Crystal in the chest, it reads them all as item.tcicrystals@0 rather then 1 of each tcicrystals@0, @1, @4, and @5. So i get an output of 4 Vis Crystals.
In my code I do have some things commented out, which in on purpose until I am able to get the items that I am having problems with working and know how to fix the rest of them.
Any help would be greatly appreciated. Thank you all in advance
------------- Load API for sensors ------------
os.unloadAPI("sensors")
os.loadAPI("/rom/apis/sensors")
------------- Dictionary Printer --------------
function printDict(data)
for i,v in pairs(data) do
print(tostring(i).." - "..tostring(v))
end
end
----------------Table Sum Function-------------------------------
function sum(data)
local sum = 0
for k,v in pairs(data) do
sum = sum + v
end
return sum
end
------------- TheCode -------------------------
--Specify Monitor Position
mon = peripheral.wrap('top')
--what side is controller on?
ctrl = sensors.getController()
--Specify the sensor
data = sensors.getSensors(ctrl)
quarrySensor = data[1]
--specify the probe(s)
data = sensors.getProbes(ctrl,quarrySensor)
inventoryContent = data[3]
--specify sensor target
data = sensors.getAvailableTargetsforProbe(ctrl,quarrySensor,inventoryContent)
quarryChest = data[5]
local pattern = "^(%d+)%*(%a+%.?%a+)@(%d+)"
local g = 0
local h = 1
while g ~= h do
local tableDirt = {}
local tableCobblestone = {}
--local tableMossStone = {}
local tableSand = {}
--local tableSandStone = {}
local tableGravel = {}
local tableObsidian = {}
local tableLapis = {}
local tableIronOre = {}
local tableGoldOre = {}
local tableCopperOre = {}
local tableTinOre = {}
local tableSilverOre = {}
local tableCoal = {}
local tableDiamond = {}
local tableRedstone = {}
local tableClay = {}
local tableFlint = {}
local tableUraniumOre = {}
--local tableEmerald = {}
local tableRuby = {}
--local tableSapphire = {}
local tableMarble = {}
--local tableBasaltCobble = {}
local tableVisCrystal = {}
--local tableVaporousCrystal = {}
--local tableAquaousCrystal = {}
--local tableFireyCrystal = {}
--local tableEarthenCrystal = {}
--local tableTaintedCrystal = {}
--local tableTungstonOre = {}
--local tableCinnabarOre = {}
--local tableNikolite = {}
data = sensors.getSensorReadingAsDict(ctrl,quarrySensor,quarryChest,inventoryContent)
--printDict(data)
mon.setTextScale(0.5)
mon.clear()
mon.setCursorPos(1,1)
term.redirect(mon)
term.clear()
--term.setCursorPos(2,2)
for i = 1, #data do
local amount, item, slot = string.match( data[i], pattern )
if item == "tile.dirt" then
table.insert(tableDirt,amount)
end
if item == "tile.stonebrick" then
table.insert(tableCobblestone,amount)
end
if item == "tile.sand" then
table.insert(tableSand,amount)
end
if item == "tile.gravel" then
table.insert(tableGravel,amount)
end
if item == "tile.obsidian" then
table.insert(tableObsidian,amount)
end
if item == "item.coal" then
table.insert(tableCoal,amount)
end
if item == "item.emerald" then
table.insert(tableDiamond,amount)
end
if item == "item.redstone" then
table.insert(tableRedstone,amount)
end
if item == "item.clay" then
table.insert(tableClay,amount)
end
if item == "item.itemOreUran" then
table.insert(tableUraniumOre,amount)
end
-- if item == "item.dyepowder@4" then
-- table.insert(tableLapis,amount)
-- end
-- if item == "null@1" then
-- table.insert(tableEmerald,amount)
-- end
if item == "null" then
table.insert(tableRuby,amount)
end
-- if item == "null@2" then
-- table.insert(tableSapphire,amount)
-- end
if item == "tile.rpstone" then
table.insert(tableMarble,amount)
end
if item == "tile.rpstone@3" then
table.insert(tableBasaltCobble,amount)
end
if item == "item.tcicrystals" then
table.insert(tableVisCrystal,amount)
end
-- if item == "item.tcicrystals@1" then
-- table.insert(tableVaporousCrystal,amount)
-- end
-- if item == "item.tcicrystals@2" then
-- table.insert(tableAquaousCrystal,amount)
-- end
-- if item == "item.tcicrystals@3" then
-- table.insert(tableEarthenCrystal,amount)
-- end
-- if item == "item.tcicrystals@4" then
-- table.insert(tableFireyCrystal,amount)
-- end
-- if item == "item.tcicrystals@5" then
-- table.insert(tableTaintedCrystal,amount)
-- end
if item == "tile.tcbcinnabarore" then
table.insert(tableCinnarbarOre,amount)
end
-- if item == "null@6" then
-- table.insert(tableNikolite,amount)
-- end
if item == "tile.oreIron" then
table.insert(tableIronOre,amount)
end
if item == "tile.oreGold" then
table.insert(tableGoldOre,amount)
end
if item == "tile.oreCopper" then
table.insert(tableCopperOre,amount)
end
if item == "tile.blockOreTin" then
table.insert(tableTinOre,amount)
end
if item == "tile.rpores@3" then
table.insert(tableSilverOre,amount)
end
--print(tostring( item ).." "..tostring(amount))
end
print("Amount")
write(" Dirt: ")
data = tableDirt
print(sum(data))
write(" Cobblestone: ")
data = tableCobblestone
print(sum(data))
write(" Sand: ")
data = tableSand
print(sum(data))
write(" Gravel: ")
data = tableGravel
print(sum(data))
write(" Obsidian: ")
data = tableObsidian
print(sum(data))
write(" Coal: ")
data = tableCoal
print(sum(data))
write(" Diamonds: ")
data = tableDiamond
print(sum(data))
write(" Redstone: ")
data = tableRedstone
print(sum(data))
write(" Clay: ")
data = tableClay
print(sum(data))
write(" Uranium Ore: ")
data = tableUraniumOre
print(sum(data))
write(" Lapis Lazuli: ")
data = tableLapis
print(sum(data))
--write(" Emeralds: ")
--data = tableEmerald
--print(sum(data))
write(" Rubies: ")
data = tableRuby
print(sum(data))
--write(" Sapphires: ")
--data = tableSapphire
--print(sum(data))
write(" Marble: ")
data = tableMarble
print(sum(data))
--write(" BasaltCobble: ")
--data = tableBasaltCobble
--print(sum(data))
write(" Vis Crystals: ")
data = tableVisCrystal
print(sum(data))
--write(" Vaporous Crystals: ")
--data = tableVaporousCrystal
--print(sum(data))
--write(" Aquaous Crystals: ")
--data = tableAquaousCrystal
--print(sum(data))
--write(" Earthen Crystals: ")
--data = tableEarthenCrystal
--print(sum(data))
--write(" Firey Crystals: ")
--data = tableFireyCrystal
--print(sum(data))
--write(" Tainted Crystals: ")
--data = tableTaintedCrystal
--print(sum(data))
write(" Iron Ore: ")
data = tableIronOre
print(sum(data))
write(" Gold Ore: ")
data = tableGoldOre
print(sum(data))
write(" Copper Ore: ")
data = tableCopperOre
print(sum(data))
write(" Tin Ore: ")
data = tableTinOre
print(sum(data))
write(" Silver Ore: ")
data = tableSilverOre
print(sum(data))
sleep(1)
end