I maded an simple script
For open your modem to the rednet
Code: pastebin get s2iV8xug rnet
Type in: rnet and your done!
Notice place the modem on the left side
local function openNet()
local listOfSides = rs.getSides()
for i = 1,6 do
if peripheral.isPresent(listOfSides[i]) and peripheral.getType(listOfSides[i]) == "modem" then
rednet.open(listOfSides[i])
return listOfSides[i]
end
end
return false
end
local side = openNet()
if side then
print("rednet Open "..side)
else
print("no modem")
end
local function openNet() -- this defines a function
local listOfSides = rs.getSides() -- this gets a list of the sides the computer has top bottom back front left right
for i = 1,6 do -- this creats a loop that will run 6 times eatch loop i will increase by one
if peripheral.isPresent(listOfSides[i]) and peripheral.getType(listOfSides[i]) == "modem" then -- if there is a peripheral and it is a modem then
rednet.open(listOfSides[i]) -- open rednet on the side that has a modem
return listOfSides[i] -- return the side this is what the openNet friction reruns
end -- end of the IF statment
end -- end of the for i = loop
return false -- if it has checked all 6 sides and not returned then return false
end -- end of the openNet function
local side = openNet() -- this calls our function and the returned information goes into a variable called side
if side then -- if side is not false then
print("rednet Open "..side) -- print the side name we opened
else -- else if side is false then
print("no modem") -- print we have found no modem
end -- end of second IF statement
if peripheral.getType("left") == "modem" then
rednet.open("left")
elseif peripheral.getType("right") == "modem" then
rednet.open("right")
elseif peripheral.getType("top") == "modem" then
rednet.open("top")
elseif peripheral.getType("bottom") == "modem" then
rednet.open("bottom")
end
And that makes it so every turtle/comp that turns on checks for modems and turns them on.what about the back or front?I just put this in the os startup script:And that makes it so every turtle/comp that turns on checks for modems and turns them on.if peripheral.getType("left") == "modem" then rednet.open("left") elseif peripheral.getType("right") == "modem" then rednet.open("right") elseif peripheral.getType("top") == "modem" then rednet.open("top") elseif peripheral.getType("bottom") == "modem" then rednet.open("bottom") end
what about the back or front?I just put this in the os startup script:And that makes it so every turtle/comp that turns on checks for modems and turns them on.if peripheral.getType("left") == "modem" then rednet.open("left") elseif peripheral.getType("right") == "modem" then rednet.open("right") elseif peripheral.getType("top") == "modem" then rednet.open("top") elseif peripheral.getType("bottom") == "modem" then rednet.open("bottom") end
Says who? The code would open only one modem. And even if there where more than one open it would send it just once.and if you have more than one it will broadcast X times the signal. for example if you have three connected you will send the same signal three times.
Says who? The code would open only one modem. And even if there where more than one open it would send it just once.
I'm just gonna own all of you right now with this code:Happy understanding! This only works in Version 1.45 PR1 of ComputerCraftterm.clear() term.setCursorPos(1,1) for n,m in ipairs(rs.getSides()) do term.setTextColor(colors.yellow) write("Opening modem: ") term.setTextColor(colors.red) write(m) term.setTextColor(colors.green) write(".") rednet.open(m) end term.setTextColor(colors.white)
Happy understanding! This only works in Version 1.45 PR1 of ComputerCraft
tSides = { "top","bottom","back","left","right","front" }
for i = 1,#tSides do
if peripheral.getType( tSide[i] ) == "modem" then
rednet.open( tSide[i] )
end
end
local tSides = { "top","bottom","back","left","right","front" }
for i = 1,#tSides do
if peripheral.getType( tSide[i] ) == "modem" and not rednet.isOpen( tSides[i] ) then
rednet.open( tSide[i] )
elseif peripheral.getType( tSide[i] == "modem" and rednet.isOpen( tSides[i] ) then
print( "Modem is open on the "..tSides[i].."!" )
else
print( "No modem found!" )
end
end