View difference between Paste ID: 7W5mjWNh and 9rAdFy6d
SHOW: | | - or go back to the newest paste.
1
print("Spacial Controls:")
2
print("W/S = Forward/Back")
3
print("A/D = Turn Left/Right")
4
print("Space/Shift = Move Up/Down")
5
print("Other Commands:")
6
print("ESC = Exit Program/Exit Turtle Interface")
7
print("R = Refuel from any slot")
8
9
function forward()
10
  turtle.forward()
11
end
12
13
function back()
14
  turtle.back()
15
end
16
17
function lt()
18
  turtle.turnLeft()
19
end
20
21
function rt()
22
  turtle.turnRight()
23
end
24
25
function up()
26
  turtle.up()
27
end
28
29
function down()
30
  turtle.down()
31
end
32
33
function refuel()
34
  for i = 1, 16 do
35
    turtle.select(i)
36
    turtle.refuel(64)
37
  end
38
end
39
40
function terminate()
41
  os.reboot()
42
end
43
44
commands = {[17] = forward,  [31] = back,  [30] = lt,  [32] = rt, [57] = up, [42] = down, [19] = refuel, [1] = terminate}
45
46
while true do
47
event, button = os.pullEvent("key")
48
fn = commands[button]
49
50
  if fn ~= nil then
51
    fn()
52
  end
53
end