Advertisement
Guest User

nanotest1

a guest
Feb 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. local event = require('event')
  2. local component = require('component')
  3. local modem = component.modem
  4. local computer = component.computer
  5. local port = 1211
  6. local head = 'nanomachines'
  7. local tot = 18 --getTotalInputCount
  8. local msg = nil
  9. local print = component.chat.say
  10. modem.open(port)
  11. modem.broadcast(port, head, 'setResponsePort', port)
  12.  
  13. local function get()
  14.   modem.broadcast(port, head, 'getActiveEffects')
  15.   msg = {event.pull('modem_message')}
  16.   if msg[6] == head and msg[7] == 'effects' then
  17.     print(msg[8])
  18.   end
  19. end
  20.  
  21. local function test(n, st)
  22.   modem.broadcast(port, head, 'setInput', n, st)
  23.   msg = {event.pull('modem_message')}
  24.   if msg[6] == head and msg[7] == 'setInput' and msg[8] == n and msg[9] == st then
  25.     print(n, st)
  26.   end
  27. end
  28.  
  29. for i = 1, tot do
  30.   for j = 1, tot do
  31.     if i ~= j then
  32.       test(i, true)
  33.       test(j, true)
  34.       get()
  35.       print('Activated: '.. i ..' and '.. j .. '\n')
  36.       test(i, false)
  37.       test(j, false)
  38.     end
  39.   end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement