Advertisement
DigitalZilla

mystcraft_PortalTurtle

Sep 14th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1. rednet.open("right");
  2.  
  3. Data = {
  4.     [2] = "PowerPlant",
  5.     [3] = "Factory",
  6.     [4] = "mtFluff",
  7.     [5] = "SacredTree"
  8. }
  9.  
  10. function returnPickedUpBook()
  11.     for i, v in ipairs(Data) do
  12.         local count = turtle.getItemCount(i);
  13.         if (count == 0) then
  14.             turtle.select(1);
  15.             turtle.transferTo(i);
  16.             break;
  17.         end
  18.     end
  19. end
  20.  
  21. while true do
  22.     local sender, msg = rednet.receive();
  23.  
  24.     local id = tonumber(msg);
  25.     if (id) then
  26.         local pickedUpBook = turtle.suck();
  27.         if (pickedUpBook) then
  28.             returnPickedUpBook();
  29.         end
  30.  
  31.         if (Data[id]) then
  32.             turtle.select(id);
  33.             turtle.drop();
  34.         end
  35.     end
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement