Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chestIDsouth = {0,1,2,3,4,5,6,7}
- chests = {}
- local tItemTbl = {}
- direction = 4
- function loadChests()
- for i = 1, #chestIDsouth do
- chests[i] = peripheral.wrap("diamond_chest_"..tostring(chestIDsouth[i-1])
- end
- end
- function buildChestsItemList()
- local tblItemNames = {}
- for i = 1, #chestIDsouth do
- if chests[i-1] ~= nil then
- for j = 1, 108 do
- item = chests[i].getStackInSlot(j-1)
- if item ~= nil then
- name = item["name"]
- table.insert(tItemNames, row)
- end
- end
- end
- end
- return tblItemNames
- end
- function checkForNewItems(tblItemNames)
- for i = 1, #tblItemNames do
- if doesContain(tblItemNames[i]) == false then
- printf("Missing item cost for: " .. tblItemNames[i])
- printf("What should it cost? (just hit enter to skip)")
- cost = read()
- if cost ~= nil then
- row = (tblItemNames[i], tonumber(cost))
- table.insert(tItemTbl, row)
- end
- end
- end
- end
- function doesContain(name)
- for i = 1, #tItemTbl do
- if tItemTbl[i][1] == name then
- return true
- end
- end
- return false
- end
- function loadTbl()
- if fs.exists("tItemTbl") then
- local file = fs.open("tItemTbl","r")
- fileData = file.readAll()
- tItemTbl = textutils.unserialize(fileData)
- file.close()
- end
- end
- function saveTbl()
- local file = fs.open("tItemTbl", "w")
- file.write(textutils.serialize(tItemTbl))
- file.close()
- end
- loadTbl()
- if tItemTbl == nil then
- tItemTbl = {}
- end
- iList = buildChestsItemList()
- checkForNewItems(iList)
- saveTbl()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement