add the full code to the top of your program and it will work or just use the function it is up to you.
line three can be substituted with
local listOfSides = { "top" , "bottom" , "front" , "left" , "right" , "back" }
but not recommended
Posted 29 March 2012 - 07:00 AM
Posted 29 March 2012 - 07:10 AM
Posted 29 March 2012 - 07:33 AM
Posted 29 March 2012 - 07:57 AM
Posted 29 March 2012 - 10:47 AM
-- Untested code
local function openRednet()
for _,side in ipairs({"top", "bottom", "front", "left", "right", "back"}) do
if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
rednet.open(side)
return side
end
end
print("no wifi present")
end
modemSide = openRednet()
if modemSide == nil then
print("No modem connected")
else
print("Opened modem on "..modemSide)
end
Posted 29 March 2012 - 11:28 AM
for _,side in ipairs({"top", "bottom", "front", "left", "right", "back"}) do
... it might be better to use this instead:for _,side in ipairs(rs.getSides()) do
Posted 29 March 2012 - 12:58 PM
immibis, on 29 March 2012 - 10:47 AM, said:
Espen, on 29 March 2012 - 11:28 AM, said:
for _,side in ipairs({"top", "bottom", "front", "left", "right", "back"}) do
... it might be better to use this instead:for _,side in ipairs(rs.getSides()) do
Posted 29 March 2012 - 01:41 PM
BigSHinyToys, on 29 March 2012 - 12:58 PM, said:
Espen, on 29 March 2012 - 11:28 AM, said:
for _,side in ipairs({"top", "bottom", "front", "left", "right", "back"}) do
... it might be better to use this instead:for _,side in ipairs(rs.getSides()) do
Posted 29 March 2012 - 02:04 PM
Posted 29 March 2012 - 02:57 PM
Wolvan, on 29 March 2012 - 02:04 PM, said:
Posted 29 March 2012 - 05:06 PM
Posted 29 March 2012 - 05:24 PM
BigSHinyToys, on 29 March 2012 - 02:57 PM, said:
Wolvan, on 29 March 2012 - 02:04 PM, said:
Posted 29 March 2012 - 06:30 PM
Wolvan, on 29 March 2012 - 05:24 PM, said:
Posted 29 March 2012 - 07:33 PM
local listOfSides = rs.getSides() for key, value in pairs( listOfSides ) do -- Do something end
for key, value in pairs( rs.getSides() ) do -- Do something end
Posted 29 March 2012 - 07:49 PM
BigSHinyToys, on 29 March 2012 - 06:30 PM, said:
Wolvan, on 29 March 2012 - 05:24 PM, said:
Posted 30 March 2012 - 12:06 AM
immibis, on 29 March 2012 - 10:47 AM, said:
-- Untested code
local function openRednet()
for _,side in ipairs({"top", "bottom", "front", "left", "right", "back"}) do
if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
rednet.open(side)
return side
end
end
print("no wifi present")
end
modemSide = openRednet()
if modemSide == nil then
print("No modem connected")
else
print("Opened modem on "..modemSide)
end
0 members, 1 guests, 0 anonymous users