Dima99

Ctrl

Mar 6th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. --binds
  2. one = "turtle.attack()"
  3. two = "turtle.suck(64)"
  4. three = ""
  5. four = ""
  6.  
  7. --variables
  8. botid = 2
  9.  
  10. --functions
  11. function command(msg)
  12.  rednet.send(botid, msg)
  13.  print("--> "..msg)
  14. end
  15.  
  16. function bind(key)
  17.  command("r")
  18.  sleep(0.1)
  19.  if key == keys.one then
  20.   command(one)
  21.   elseif key == keys.two then
  22.   command(two)
  23.   elseif key == keys.three then
  24.   command(three)
  25.   elseif key == keys.four then
  26.   command(four)
  27.  end
  28. end
  29.  
  30. --body
  31. rednet.open("back")
  32. relay = true
  33. while relay do
  34.  event, key = os.pullEvent()
  35.  if key == keys.leftAlt then
  36.   relay = false
  37.   term.clear()
  38.   term.setCursorPos(1,1)
  39.   elseif key == keys.leftCtrl then
  40.   command("lCtrl")
  41.   elseif key == keys.w then
  42.   command("w")
  43.   elseif key == keys.s then
  44.   command("s")
  45.   elseif key == keys.a then
  46.   command("a")
  47.   elseif key == keys.d then
  48.   command("d")
  49.   elseif key == keys.space then
  50.   command("space")
  51.   elseif key == keys.leftShift then
  52.   command("lShift")
  53.   elseif key == keys.e then
  54.   command("e")
  55.   elseif key == keys.f then
  56.   command("f")
  57.   elseif key == keys.g then
  58.   command("g")
  59.   elseif key == keys.q then
  60.   command("q")
  61.   write("slot >> ")
  62.   sleep(0.1)
  63.   ans = read()
  64.   command(tostring(ans))
  65.   elseif key == keys.r then
  66.   command("r")
  67.   write("command >> ")
  68.   sleep(0.1)
  69.   ans = read()
  70.   command(tostring(ans))
  71.   elseif key == keys.one then
  72.   bind(key)
  73.   elseif key == keys.two then
  74.   bind(key)
  75.   elseif key == keys.three then
  76.   bind(key)
  77.   elseif key == keys.four then
  78.   bind(key)
  79.  end
  80. end
Add Comment
Please, Sign In to add comment