Advertisement
guitarplayer616

Scanner/Detector/EventPuller

May 26th, 2015
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. local events = {}
  2. local inspects = {}
  3. local scans = 0
  4. local w,h = term.getSize()
  5. term.clear()
  6. term.setCursorPos(1,1)
  7. term.setTextColor(colors.green)
  8. print("Scan: ")
  9. term.setTextColor(colors.red)
  10. print("Inspect: ")
  11. term.setTextColor(colors.blue)
  12. print("Event: ")
  13. term.setTextColor(colors.gray)
  14. while true do
  15.   events = {os.pullEvent()}
  16.   if events[1] == "mouse_click" and events[4] == 2 and events[3] < 7 then
  17.     term.setCursorPos(10,2)
  18.     inspects = {turtle.inspect()}
  19.     write(tostring(inspects[1]).." ")
  20.     if inspects[1] then
  21.       write(inspects[2].name.." "..inspects[2].metadata)
  22.       local x,y = term.getCursorPos()
  23.       write(string.rep(" ",w-x))
  24.     end
  25.   end
  26.   if events[1] == "mouse_click" and events[4] == 1 and events[3] < 5 then
  27.     term.setCursorPos(7,1)
  28.     scans = turtle.getItemDetail()
  29.     if scans then
  30.       write(scans.name.." "..scans.damage.." "..scans.count)
  31.       local x,y = term.getCursorPos()
  32.       write(string.rep(" ",w-x))
  33.     end
  34.   end
  35.   if events[1] == "char" and tonumber(events[2])~=nil and tonumber(events[2])~=0 then
  36.     turtle.select(tonumber(events[2]))
  37.     local data = turtle.getItemDetail()
  38.     term.setCursorPos(7,1)
  39.     if data then
  40.       write(data.name.." "..data.damage.." "..data.count)
  41.       local x,y = term.getCursorPos()
  42.       write(string.rep(" ",w-x))
  43.     end
  44.   else
  45.     term.setCursorPos(7,1)
  46.     print("No item in selected slot")
  47.   end
  48.   term.setCursorPos(1,4)
  49.   for i=1,#events do
  50.     write(events[i])
  51.     local x,y = term.getCursorPos()
  52.     write(string.rep(" ",w-x))
  53.     write("\n")
  54.   end
  55.   for i=1,4 do
  56.     term.setCursorPos(1,#events+i+3)
  57.     write(string.rep(" ",w))
  58.   end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement