Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("bottom")
- --shell.setDir("/BillBodkinCompCraft")
- storageBot = 0
- if fs.exists("/BillBodkinCompCraft/chestData") then
- else
- shell.run("pastebin get vUypHecK /BillBodkinCompCraft/chestData")
- end
- function load(name)
- local file = fs.open(name,"r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- function save(table,name)
- local file = fs.open(name,"w")
- file.write(textutils.serialize(table))
- file.close()
- end
- function getItemsChest(id)
- i = 1
- while i < #chests + 2 do
- --print("i: "..i)
- --print(chests[i])
- if tonumber(i) > #chests then
- if tonumber(messageId) == storageBot then
- --print("b")
- table.insert(chests, tonumber(i), itemChestToFind)
- --print("bc")
- return tostring(i)
- else
- return "not avaliable to retrive"
- end
- else
- --print("a")
- if tostring(chests[i]) == itemChestToFind then
- --print("ac")
- return tostring(i)
- end
- end
- i = i + 1
- end
- end
- chests = load("/BillBodkinCompCraft/chestData")
- itemChestToFind = "0"
- chestForItem = 0
- i = 1
- messageId = 0
- on = true
- print("Ready To Retrieve Data")
- while on == true do
- messageId, message, protocol = rednet.receive()
- print("ID: "..messageId.." | Item To Locate: "..message)
- itemChestToFind = tostring(message)
- if itemChestToFind == "wallBuilder" then
- chestForItem = tostring(#chests)
- else
- chestForItem = getItemsChest(itemChestToFind)
- end
- print("Item's Chest: "..chestForItem)
- rednet.send(messageId, chestForItem)
- save(chests,"/BillBodkinCompCraft/chestData")
- end
- save(chests,"/BillBodkinCompCraft/chestData")
- rednet.close("bottom")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement