Advertisement
sanovskiy

Monitor testing

Nov 14th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. Side = { "bottom", "top", "back", "left", "right" }
  2. for i = 1,5 do
  3.   print(Side[i].." : "..tostring(peripheral.getType(Side[i])))
  4.   if peripheral.getType(Side[i]) == "modem" then
  5.     modem = peripheral.wrap(Side[i])
  6.     print("Using modem at "..Side[i])
  7.     break
  8.   end
  9. end
  10. if modem == nil then
  11.     error("No modem found!")
  12. end
  13. peripherals = modem.getNamesRemote()
  14.  
  15. monitors = {}
  16. function FindMonitors ()
  17.     counter = 1
  18.     for i = 1, #peripherals do
  19.         if modem.getTypeRemote(peripherals[i]) == "monitor" then
  20.             monitors[counter] = peripherals[i]
  21.             counter = counter+1
  22.         end
  23.     end
  24.     if (table.getn(monitors)==0) then
  25.         error("No monitors present!")
  26.     end
  27.     print(tostring(table.getn(monitors)).." monitors found")
  28. end
  29.  
  30. function printAtAll(text)
  31.     for key,val in pairs(monitors) do
  32.         modem.callRemote(val, "write", text.."\n")
  33.     end
  34. end
  35.  
  36. FindMonitors()
  37. printAtAll("Hello, world!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement