Zatilla7

Auto-connection test

Apr 19th, 2014
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. for _,side in pairs(rs.getSides()) do -- this uses the redstone.getSides() call to look at each side of the computer
  2. if peripheral.isPresent(side) then -- if we find a perhiperal...
  3. if peripheral.getType(side) == "monitor" then -- then we try to identify if it's one of the peripherals we're looking for
  4. mon = peripheral.wrap(side) -- if it's what we're looking for, we wrap it
  5. elseif peripheral.getType(side) == "tank" then
  6. fluidTank = peripheral.wrap(side)
  7. elseif peripheral.getType(side) == "modem" then
  8. if not peripheral.call(side,"isWireless") then -- eliminate wireless modems
  9. local mdm = peripheral.wrap(side) -- temporarily wrap the modem
  10.  
  11. for e,f in pairs(mdm.getNamesRemote()) do -- look for attached peripherals
  12. if string.sub(f,1,4) == 'tank' then -- if we find a tank
  13. fluidTank = peripheral.wrap(f) -- wrap it
  14. elseif string.sub(f,1,7) == 'monitor' then
  15. mon = perihperal.wrap(f)
  16. end
  17. end
  18. end
  19. end
  20. end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment