Advertisement
Guest User

RobotReciver

a guest
Jan 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. component = require "component"
  2. modem = component.modem
  3. event = require "event"
  4. robot = require "robot"
  5. modem.open(8267)
  6.  
  7. while true do
  8.   local _, _, from, port, _, message = event.pull("modem_message")
  9.   if message == "Forward" then
  10.     _, output = robot.forward()
  11.   elseif message == "Turn Right" then
  12.     _, output = robot.turnRight()
  13.   elseif message == "Turn Left" then
  14.     _, output = robot.turnLeft()
  15.   elseif message == "Backward" then
  16.     _, output = robot.back()
  17.   elseif message == "Up" then
  18.     _, output = robot.up()
  19.   elseif message == "Down" then
  20.     _, output = robot.down()
  21.   elseif message == "Succ" then
  22.     robot.suck()
  23.   elseif message == "Drop" then
  24.     robot.drop()
  25.   elseif message == "Place" then
  26.     robot.place()
  27.   elseif message == "Swing" then
  28.     robot.swing()
  29.   elseif message == "Equip" then
  30.     component.inventory_controller.equip()
  31.   elseif message == "Swing Up" then
  32.     robot.swingUp()
  33.   elseif message == "Swing Down" then
  34.     robot.swingDown()
  35.   elseif message == "Turn Around" then
  36.     robot.turnAround()
  37.   elseif string.sub(message, 1, 15) == "Inv Slot Change" then
  38.     slot = string.sub(message, 16, -1)
  39.     robot.select(tonumber(slot))
  40.   else print("Invalid Command")
  41.   end
  42.   if output then
  43.     modem.broadcast(8268, output)
  44.   end
  45.   print("Got a message from " .. from .. " on port " .. port .. ": " .. tostring(message))
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement