Advertisement
ComputerMan123

Monitor Program Runner (MultiMon)

Nov 3rd, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. --# Load the API
  2. os.loadAPI('/multiMon')
  3.  
  4. --# Create the monitors object (the monitors are arranged in the world the same way you see them in the table below).
  5. local monitorSetup = {
  6.   {peripheral.wrap('monitor_22'), peripheral.wrap('monitor_23'), peripheral.wrap('monitor_24')},
  7.   {peripheral.wrap('monitor_25'), peripheral.wrap('monitor_26'), peripheral.wrap('monitor_27')},
  8.   {peripheral.wrap('monitor_19'), peripheral.wrap('monitor_20'), peripheral.wrap('monitor_21')},
  9. }
  10.  
  11. --# Create the virtual monitor (will also return the handle).
  12. local disp = multiMon.create('myMonitor', monitorSetup)
  13.  
  14. --# Showcasing some basic functions.
  15. disp.setTextScale(0.5)
  16. if disp.isColour() then
  17.   disp.setTextColour(colours.white)
  18.   disp.setBackgroundColour(colours.black)
  19. end
  20. disp.setCursorBlink(false)
  21. disp.clear()
  22. disp.setCursorPos(1, 1)
  23. local width, height = disp.getSize()
  24.  
  25. --# Some setup is needed for paint.
  26. parallel.waitForAny(
  27.   function()
  28.    --# Since paint is meant to work only on the terminal, we need to catch all touch events and turn them into mouse_click events.
  29.    --# This happens in the background while paint is running.
  30.    while true do
  31.         local ev = {os.pullEvent('monitor_touch')}
  32.         if ev[2] == 'myMonitor' then
  33.          os.queueEvent('mouse_click', 1, ev[3], ev[4])
  34.         end
  35.    end
  36.   end,
  37.   function()
  38.    --# Since paint uses 'term' internally, we need to set 'disp' to act as 'term'.
  39.    term.redirect(disp)
  40.    --# Run the program with 'image' as the argument.
  41.    shell.run('/rom/programs/advanced/paint', 'image')
  42.   end
  43. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement