Advertisement
montana_1

Print Turtle Inventory As Square Table

Oct 13th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. function dispInvAsTbl(monitor,x,y) --Displays the inventory of the turtle as a 4 x 4 table relative to the x and y coordinates specified.
  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. mon = peripheral.wrap("left")
  15. mon.clear()
  16.  
  17. local x = read()
  18. local y = read()
  19. dispInvAsTbl(mon,x,y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement