Advertisement
davedumas0

thaumcraftThingy(opencomputers Robot)

Apr 2nd, 2022
833
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. -- robot config https://cdn.discordapp.com/attachments/358433226290626564/959698093421518868/unknown.png
  2. -- added a tier 2 wireless card in  the one available slot
  3.  
  4.  
  5. local event = require("event")
  6. local component = require("component")
  7. local os = require("os")
  8. local term = require("term")
  9. local robot = require("robot")
  10. local modem = component.modem
  11.  
  12. local posX = 0
  13. local posY = 0
  14. local posZ = 0
  15. local vector = "north"
  16. local message = " "
  17. local robotBusy = 0
  18. local variables = {}
  19.  
  20.  
  21. function modemListen()
  22. modem.open(5)
  23.   _, _, from, port, _, msg = event.pull(0.001,  "modem_message")
  24.  if msg ~= nil then
  25.   message = msg
  26.  else
  27.   message = " "
  28.  end
  29. end
  30.  
  31. function listenForCommands()
  32.  
  33.  if message == "robotTurnLeft" then
  34.  robot.turnLeft()
  35.  end
  36.  
  37.  if message == "robotTurnRight" then
  38.  robot.turnRight()
  39.  end
  40.  
  41.  if message == "robotGoForward" then
  42.  robot.forward()
  43.  end
  44.  
  45.  if message == "robotGoBack" then
  46.  robot.back()
  47.  end
  48.  
  49.  if message == "robotGoUp" then
  50.  robot.up()
  51.  end
  52.  
  53.  if message == "robotGoDown" then
  54.  robot.down()
  55.  end
  56.  
  57.  
  58. end
  59.  
  60.  
  61. function sendMsgToComputer (msg)
  62.  modem.open(5)
  63.  modem.broadcast(5, tostring(msg))
  64.  modem.close(5)
  65. end
  66.  
  67.  
  68.  
  69. while true do
  70.  modemListen()
  71. listenForCommands()
  72.  
  73.  
  74.  
  75. end
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement