Advertisement
montana_1

Cobblestone Miner

Oct 7th, 2014
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. function dispInvAsTbl(monitor,x,y)
  2.     local c = 1
  3.     while( c < 17) do
  4.         monitor.setCursorPos((c - (4 * (math.ceil(c/4) - 1))) * 3 + x - 3, math.ceil(c/4) + y - 1)
  5.         monitor.write(string.sub(turtle.getItemCount(c), -2))
  6.         monitor.setCursorPos((c - (4 * (math.ceil(c/4) - 1))) * 3 + x - 1, math.ceil(c/4) + y - 1)
  7.         if((c - (4 * (math.ceil(c/4) - 1))) ~= 4 ) then
  8.             monitor.write("|")
  9.         end
  10.         c = c + 1
  11.     end
  12. end
  13.  
  14. function getInv() --Returns total inventory of the turtle
  15.         local c = 1
  16.         local total = 0
  17.         while( c < 17) do
  18.                 total = total + turtle.getItemCount(c)
  19.                 c = c + 1
  20.         end
  21.         return total
  22. end
  23.  
  24. cobble = 0
  25. mon = peripheral.wrap("left")
  26. mon.clear()
  27. term.clear()
  28.  
  29. dispInvAsTbl(mon,3,3)
  30. mon.setCursorPos(3,8)
  31. mon.write(string.sub(getInv(),1))
  32.  
  33. while(1) do
  34.     if(turtle.detect() and redstone.getInput("right") and getInv() < 1024) then
  35.         turtle.dig()
  36.         cobble = cobble + 1
  37.         mon.clear()
  38.         dispInvAsTbl(mon,3,3)
  39.         mon.setCursorPos(3,8)
  40.         mon.write(string.sub(getInv(),1))
  41.        
  42.     end
  43.     mon.setCursorPos(1,1)
  44.     mon.write("C-Miner   v10.7.14")
  45.     mon.setCursorPos(1,2)
  46.     mon.write("Total Mined: ".. cobble)
  47.     mon.setCursorPos(7,8)
  48.     mon.write("/1024")
  49.    
  50.    
  51.    
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement