icdb icon

[ComputerCraft] Remote (remote)

icdb | PRO | 09/17/14 12:47:39 PM UTC | 0 ⭐ | 649 👁️ | Never ⏰ | []
Lua |

640 B

|

None

|

0 👍

/

0 👎

--remote
function clr()
    term.clear()
    term.setCursorPos(1,1)
end
 
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 modem present")
end
 
side = openRednet()
if side == nil then
print("no modem found")
else
  while true do
    clr()
    print("Enter the command")
    term.setCursorPos(2,3)
    local command = read()
    rednet.broadcast(command)
    term.setCursorPos(2,5)
    print("Sending ...")
    sleep(0.25)
  end
end

Comments