Advertisement
fatboychummy

betterMonitor.lua

Feb 3rd, 2020
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. local tArgs = {...}
  2. local monPeriph = tArgs[1]
  3.  
  4. local mon = peripheral.wrap(monPeriph)
  5.  
  6. local oldTerm = term.redirect(mon)
  7.  
  8. local function a()
  9.   while true do
  10.     local ev, sd, x, y = os.pullEvent("monitor_touch")
  11.     if sd == monPeriph then
  12.       os.queueEvent("mouse_click", 1, x, y)
  13.       os.sleep()
  14.       os.queueEvent("mouse_up", 1, x, y)
  15.     end
  16.   end
  17. end
  18.  
  19. local function b()
  20.   shell.run(table.unpack(tArgs, 2))
  21. end
  22.  
  23. local ok, err = pcall(parallel.waitForAny, a, b)
  24.  
  25. term.redirect(term.native())
  26.  
  27. if not ok then
  28.   printError(err)
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement