Derek1017

Rednet Test 1

Jul 24th, 2015
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. -- wifi modem test --
  2. local function openRednet()
  3. local listOfSides = rs.getSides()
  4. local listofPossibles = {}
  5. local counter1 = 0
  6. while true do
  7.   counter1 = counter1 +1
  8.  
  9.   if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then
  10.    table.insert(listofPossibles,tostring(listOfSides[counter1]))
  11.   end
  12.  
  13.   if counter1 == 6 and table.maxn(listofPossibles) == 0 then
  14.    print("no wifi present")
  15.    return nil
  16.   end
  17.  
  18.   if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then
  19.    rednet.open(listofPossibles[1])
  20.    return listofPossibles[1]
  21.   end
  22. end
  23. end
  24. modemOn = openRednet()
  25. if modemOn == nil then
  26. print("No WIFI Modem")
  27. print("Will shutdown in 3 seconds")
  28. sleep(3)
  29. os.shutdown()
  30. else
  31. print("Opened wifi on "..modemOn.." side")
  32. end
  33. -- wifi modem test end --
Add Comment
Please, Sign In to add comment