Advertisement
maxtorcd55

mystcraft_getbook

Apr 10th, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.07 KB | None | 0 0
  1. local chestZide = "right"
  2. local monitor = peripheral.wrap("top")
  3. local chestLoc = peripheral.wrap(chestZide)
  4. local portalLoc = peripheral.wrap("back")
  5.  
  6. monitor.setTextScale(1)
  7.  
  8. portalLoc.pushItem("north",1,64,1)
  9. for i = 1, 16 do chestLoc.pullItem("west",i,64) end
  10. sleep(1)
  11.  
  12. local chest = peripheral.call(chestZide, "getAllStacks")
  13. local chestInvSize = peripheral.call(chestZide, "getInventorySize")
  14. print("invSize: "..chestInvSize)
  15.  
  16. local allBooks = {}
  17. local bookid = 0
  18. for i = 1, chestInvSize do
  19.     if chest[i] ~= nil then
  20.         if chest[i]["id"] == 8957 then
  21.             bookid = bookid + 1
  22.             allBooks[bookid] = {"name","slot","actief"}
  23.             allBooks[bookid]["name"] = chest[i]["name"]
  24.             allBooks[bookid]["slot"] = i
  25.             allBooks[bookid]["actief"] = 0
  26.         end
  27.     end
  28. end
  29.  
  30. bookid = bookid + 1
  31. allBooks[bookid] = {"name","slot","actief"}
  32. allBooks[bookid]["name"] = "None"
  33. allBooks[bookid]["slot"] = 1
  34. allBooks[bookid]["actief"] = 0
  35.  
  36. while (true) do
  37.     monitor.clear()
  38.         monitor.setCursorPos(1,1)
  39.     for i = 1, #allBooks do
  40.                 monitor.setCursorPos(1,i)
  41.                 if allBooks[i]["actief"] == 0 then
  42.                         monitor.setTextColor(colors.white)
  43.             monitor.write(allBooks[i]["name"])
  44.  
  45.                 else
  46.                         monitor.setTextColor(colors.red)
  47.                         monitor.write(allBooks[i]["name"])
  48.                         monitor.setTextColor(colors.white)
  49.                 end
  50.         end
  51.     event, side, xPos, yPos = os.pullEvent("monitor_touch")
  52.  
  53.  
  54.     if allBooks[yPos] ~= nil then
  55.         for i = 1, #allBooks do allBooks[i]["actief"] = 0 end
  56.                 allBooks[yPos]["actief"] = 1
  57.         end
  58.  
  59.     portalLoc.pushItem("north",1,64)
  60.     for i = 1, 16 do chestLoc.pullItem("west",i,64) end
  61.     sleep(0.1)
  62.    
  63.         for i = 1, #allBooks do
  64.                 if allBooks[i]["actief"] == 1 then
  65.             if allBooks[i]["name"] ~= "None" then
  66.                             chestLoc.pushItem("west",allBooks[i]["slot"],1)
  67.                 sleep(0.1)
  68.                             portalLoc.pullItem("north",1,64,1)
  69.             end
  70.                 end
  71.         end  
  72.  
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement