Guest User

BowSort

a guest
Aug 22nd, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. local slot = {
  2.   "input", --1
  3.   "bow",
  4.   "unbreaking_1", --3
  5.   "unbreaking_2", --4
  6.   "unbreaking_3", --5
  7.   "punch_1","     --6
  8.  "power_1",      --7
  9.  "power_2",      --8
  10.  "power_3",      --9
  11. }
  12.  
  13. local function output(str,line)
  14.  term.setCursorPos(1,line)
  15.  term.clearLine()
  16.  term.write(str)
  17. end
  18.  
  19. local function compare()
  20.  turtle.select(1)
  21.  local s
  22.  for s=2,#slot do
  23.    if turtle.compareTo(s) then
  24.      return slot[s]
  25.    end
  26.  end
  27.  return false
  28. end
  29.  
  30. term.setCursorPos(1,1)
  31. term.clear()
  32. print(string.format("#%d %s",
  33.  os.getComputerID(),
  34.  os.getComputerLabel()))
  35. local t = os.startTimer(.2)
  36.  
  37. while true do
  38.  local e,p = os.pullEvent()
  39.  if e=="turtle_inventory" then
  40.    output("Manage inventory",2)
  41.    local test = compare()
  42.    output("manage inventory: "..(test and test or "unknown"))
  43.    if not test then
  44.      --unusual enchant
  45.    elseif test=="bow" then
  46.      --casual bow
  47.    else
  48.      --usual enchant
  49.    end
  50.  end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment