Advertisement
Dima99

Bot

Mar 6th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | None | 0 0
  1. --variables
  2. ctrlid = 3
  3. slot = 1
  4.  
  5. --functions
  6. function command(msg)
  7.  local h = fs.open("temp", "w")
  8.  h.write(msg)
  9.  h.close()
  10.  shell.run("temp")
  11.  fs.delete("temp")
  12. end
  13.  
  14. function pm(msg)
  15.  print("<-- "..tostring(msg))
  16. end
  17.  
  18. --body
  19. rednet.open("left")
  20. relay = true
  21. while relay do
  22.  id, msg = rednet.receive()
  23.  if id == ctrlid then
  24.   pm(msg)
  25.   if msg == "lCtrl" then
  26.    relay = false
  27.    term.clear()
  28.    term.setCursorPos(1, 1)
  29.    elseif msg == "w" then
  30.    turtle.forward()
  31.    elseif msg == "s" then
  32.    turtle.back()
  33.    elseif msg == "a" then
  34.    turtle.turnLeft()
  35.    elseif msg == "d" then
  36.    turtle.turnRight()
  37.    elseif msg == "space" then
  38.    turtle.up()
  39.    elseif msg == "lShift" then
  40.    turtle.down()
  41.    elseif msg == "e" then
  42.    turtle.equipRight()
  43.    elseif msg == "f" then
  44.    turtle.dig()
  45.    elseif msg == "g" then
  46.    turtle.place()
  47.    elseif msg == "q" then
  48.    idA, msgA = rednet.receive()
  49.    if idA == ctrlid then
  50.     for i = 1, 16 do
  51.      if i == tonumber(msgA) then
  52.       slot = tonumber(msgA)
  53.      end
  54.     end
  55.     turtle.select(slot)
  56.     print("<< "..tostring(slot))
  57.    end
  58.    elseif msg == "r" then
  59.    idB, msgB = rednet.receive()
  60.    if idB == ctrlid then
  61.     command(msgB)
  62.     print("<< "..msgB)
  63.    end
  64.   end
  65.  end
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement