icdb

[ComputerCraft] Remote (remote)

Sep 17th, 2014
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. --remote
  2. function clr()
  3.     term.clear()
  4.     term.setCursorPos(1,1)
  5. end
  6.  
  7. local function openRednet()
  8.   for _,side in ipairs({"top", "bottom", "front", "left", "right", "back"}) do
  9.     if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
  10.       rednet.open(side)
  11.       return side
  12.     end
  13.   end
  14.   print("no modem present")
  15. end
  16.  
  17. side = openRednet()
  18. if side == nil then
  19. print("no modem found")
  20. else
  21.   while true do
  22.     clr()
  23.     print("Enter the command")
  24.     term.setCursorPos(2,3)
  25.     local command = read()
  26.     rednet.broadcast(command)
  27.     term.setCursorPos(2,5)
  28.     print("Sending ...")
  29.     sleep(0.25)
  30.   end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment