BlueMond

chest inspect

Aug 21st, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. local version = "1.24"  --change this to allow for an update (3 chars only)
  2. local filename = "react"  --change this to the name of the file holding this program
  3. local paste = "y1hvbQ4y"  --change this to the pastebin entry code
  4.  
  5. local function update()
  6.         local url = "http://pastebin.com/raw/"..paste
  7.         local temp = http.get(url)
  8.         local ver = string.sub(temp.readLine(), 18, 21)
  9.         print(version..":"..ver)
  10.         if ver ~= version then
  11.                 fs.delete(filename)
  12.                 shell.run("pastebin get "..paste.." "..filename)
  13.                 shell.run(filename)
  14.                 return true
  15.         end
  16.         return false
  17. end
  18.  
  19. --start
  20. if update() then
  21.     error()
  22. end
  23. shell.run("clear")
  24.  
  25. --not mine
  26. local function split(str)
  27.     local t = {}  -- NOTE: use {n = 0} in Lua-5.0
  28.     local fpat = "(.-)" .. ":" --character to use
  29.     local last_end = 1
  30.     local s, e, cap = str:find(fpat, 1)
  31.         while s do
  32.             if s ~= 1 or cap ~= "" then
  33.                 table.insert(t,cap)
  34.             end
  35.             last_end = e+1
  36.             s, e, cap = str:find(fpat, last_end)
  37.         end
  38.         if last_end <= #str then
  39.             cap = str:sub(last_end)
  40.             table.insert(t, cap)
  41.         end
  42.     return t
  43. end
  44.  
  45. --suck contents
  46. turtle.select(1)
  47. while turtle.suck() ~= false do end
  48.  
  49. --print details of each item in order
  50. local slot = 1
  51. h = fs.open("contents","w")
  52. while turtle.getItemDetail(slot) ~= nil do
  53.     local item = turtle.getItemDetail(slot)
  54.     local name = split(item.name)
  55.     h.writeLine(name[1])
  56.     h.writeLine(name[2])
  57.     h.writeLine(item.count)
  58.     h.writeLine("")
  59.     slot = slot + 1
  60. end
  61. h.close()
  62.  
  63. --return contents
  64. for slot=1,16,1 do
  65.     turtle.select(slot)
  66.     turtle.drop()
  67. end
  68. turtle.select(1)
Add Comment
Please, Sign In to add comment