Advertisement
Guest User

RobotController

a guest
Jan 17th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. component = require "component"
  2. modem = component.modem
  3. event = require "event"
  4. modem.open(8268)
  5.  
  6. while true do
  7.   print("Input Command: ")
  8.   command = string.lower(io.read())
  9.   if command == "forward" then
  10.     modem.broadcast(8267, "Forward")
  11.   elseif command == "turn left" then
  12.     modem.broadcast(8267, "Turn Left")
  13.   elseif command == "turn right" then
  14.     modem.broadcast(8267, "Turn Right")
  15.   elseif command == "backward" then
  16.     modem.broadcast(8267, "Backward")
  17.   elseif command == "exit" then os.exit()
  18.   elseif command == "swing" then
  19.     modem.broadcast(8267, "Swing")
  20.   elseif command == "swing up" then
  21.     modem.broadcast(8267, "Swing Up")
  22.   elseif command == "swing down" then
  23.     modem.broadcast(8267, "Swing Down")
  24.   elseif command == "equip" then
  25.     modem.broadcast(8267, "Equip")
  26.   elseif command == "place" then
  27.     modem.broadcast(8267, "Place")
  28.   elseif command == "up" then
  29.     modem.broadcast(8267, "Up")
  30.   elseif command == "down" then
  31.     modem.broadcast(8267, "Down")
  32.   end
  33.   local _, _, from, port, _, message = event.pull("modem_message")
  34.   print("Error message from "..from..": "..message)
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement