SHOW:
|
|
- or go back to the newest paste.
1 | rednet.open("top") | |
2 | - | turtleID = 111 |
2 | + | turtleID = 235 |
3 | up = " " | |
4 | front = " " | |
5 | down = " " | |
6 | actions = {} | |
7 | start = 1 | |
8 | while true do | |
9 | term.clear() | |
10 | for i = 1, #actions do | |
11 | print(actions[i]) | |
12 | end | |
13 | term.setCursorPos(1,1) | |
14 | term.clearLine() | |
15 | print("Turtle mission control") | |
16 | term.setCursorPos(1,2) | |
17 | term.clearLine() | |
18 | print(" ") | |
19 | term.setCursorPos(1,3) | |
20 | term.clearLine() | |
21 | print(up) | |
22 | term.setCursorPos(1,4) | |
23 | term.clearLine() | |
24 | print(front) | |
25 | term.setCursorPos(1,5) | |
26 | term.clearLine() | |
27 | print(down) | |
28 | term.setCursorPos(1,6) | |
29 | term.clearLine() | |
30 | print(" ") | |
31 | ||
32 | while true do | |
33 | event, key = os.pullEvent("key") | |
34 | if key == keys.w then | |
35 | action = "forward" | |
36 | - | redent.send(turtleID, "r = turtle.forward()") |
36 | + | rednet.send(turtleID, "ret = turtle.forward()") |
37 | break | |
38 | elseif key == keys.a then | |
39 | action = "left" | |
40 | - | redent.send(turtleID, "r = turtle.turnLeft()") |
40 | + | rednet.send(turtleID, "ret = turtle.turnLeft()") |
41 | break | |
42 | elseif key == keys.s then | |
43 | action = "back" | |
44 | - | redent.send(turtleID, "r = turtle.back()") |
44 | + | rednet.send(turtleID, "ret = turtle.back()") |
45 | break | |
46 | elseif key == keys.d then | |
47 | action = "right" | |
48 | - | redent.send(turtleID, "r = turtle.turnRight()") |
48 | + | rednet.send(turtleID, "ret = turtle.turnRight()") |
49 | break | |
50 | elseif key == 42 then | |
51 | action = "down" | |
52 | - | redent.send(turtleID, "r = turtle.down()") |
52 | + | rednet.send(turtleID, "ret = turtle.down()") |
53 | break | |
54 | elseif key == 57 then | |
55 | action = "up" | |
56 | - | redent.send(turtleID, "r = turtle.up()") |
56 | + | rednet.send(turtleID, "ret = turtle.up()") |
57 | break | |
58 | elseif key == 28 then | |
59 | action = "dig" | |
60 | - | redent.send(turtleID, "r = turtle.dig()") |
60 | + | rednet.send(turtleID, "ret = turtle.dig()") |
61 | break | |
62 | elseif key == keys.up then | |
63 | action = "dig up" | |
64 | rednet.send(turtleID, "ret = turtle.digUp()") | |
65 | break | |
66 | - | while os.clock - startClock < 3 do |
66 | + | elseif key == keys.down then |
67 | action = "dig down" | |
68 | rednet.send(turtleID, "ret = turtle.digDown()") | |
69 | break | |
70 | end | |
71 | end | |
72 | startClock = os.clock() | |
73 | success = false | |
74 | - | r, front, up, down = textutils.unserialize(msg) |
74 | + | while os.clock() - startClock < 3 do |
75 | id, msg = rednet.receive(1) | |
76 | - | table.insert(actions, acac) |
76 | + | |
77 | success = true | |
78 | break | |
79 | end | |
80 | end | |
81 | if not success then error("Connection lost!") end | |
82 | receiving = textutils.unserialize(msg) | |
83 | r = receiving[1] | |
84 | front = receiving[2] | |
85 | up = receiving[3] | |
86 | down = receiving[4] | |
87 | if r then | |
88 | table.insert(actions, action) | |
89 | end | |
90 | end |