Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local term = require("term")
- local gpu = component.gpu
- local meInterface = component.me_interface
- local meExport = component.me_exportbus
- local db = component.database
- local oreDict = {
- "Iron",
- "Gold",
- "Diamond",
- "Emerald",
- "Coal",
- "Redstone",
- "Nether Quartz"}
- local oreNum = {}
- local isFoundData = {}
- local Text_Name_X = 2
- local Text_Num_X = Text_Name_X + 20
- function Report_Component()
- if gpu ~= nil then
- print("Get GPU Succeed")
- else
- print("Get GPU Failed!!!")
- end
- if meInterface ~= nil then
- print("Get Interface Succeed")
- else
- print("Get Interface Failed!!!")
- end
- if meExport ~= nil then
- print("Get ExportBus Succeed")
- else
- print("Get ExportBus Failed!!!")
- end
- if db ~= nil then
- print("Get Database Succeed")
- else
- print("Get Database Failed!!!")
- end
- end
- function Add_Suffix(table_ore)
- for key,value in ipairs(table_ore) do
- table_ore[key] = value .. " Ore"
- end
- print("Add Suffix Proccess done")
- end
- function Refresh_Database()
- for key,value in ipairs(oreDict) do
- --reset old data
- isFoundData[key] = false
- oreNum[key] = 0
- local label_item = {label = value}
- local table_item = nil
- table_item = meInterface.getItemsInNetwork(label_item)
- if table_item.n == 1 then
- db.clear(key)
- local isSuccessStore = meInterface.store(table_item[1], db.address, key, 1)
- if isSuccessStore == true then
- isFoundData[key] = true
- oreNum[key] = table_item[1].size
- end
- end
- end
- print("Refresh Database proccess done")
- end
- function Print_OreInfo()
- term.clear()
- for key, value in pairs(oreDict) do
- local Height = 2 + key
- gpu.set(Text_Name_X, Height, value, false)
- if isFoundData[key] ~= true then
- gpu.set(Text_Num_X, Height, "0", false)
- else
- local table_Item = db.get(key)
- local itemNum = oreNum[key]
- gpu.set(Text_Num_X, Height, tostring(itemNum), false)
- end
- end
- end
- do
- Report_Component()
- Add_Suffix(oreDict)
- while true do
- Refresh_Database()
- Print_OreInfo()
- os.sleep(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement