-
Notifications
You must be signed in to change notification settings - Fork 0
/
Opencomputer drone remote
77 lines (68 loc) · 2.27 KB
/
Opencomputer drone remote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
component = require("component")
m=component.modem
m.broadcast(5, "drone=component.proxy(component.list('drone')())")
mover = function()
for dir in string.gmatch(line, "[^%s]+") do
round = (round+1)
if round == 1 then
direction = dir
else if round == 2 then
anzahl = dir
if anzahl == "down" then
anzahl = 0
else if anzahl == "up" then
anzahl = 1
else if anzahl == "left" then
anzahl = 2
else if anzahl == "right" then
anzahl = 3
else if anzahl == "back" then
anzahl = 4
else if anzahl == "front" then
anzahl = 5
end
end
end
end
end
end
end
end
end
if direction == "w" then
m.broadcast(5, "drone.move("..anzahl..",0,0)")
else if direction == "s" then
m.broadcast(5, "drone.move(-"..anzahl..",0,0)")
else if direction == "d" then
m.broadcast(5, "drone.move(0,0,"..anzahl..")")
else if direction == "a" then
m.broadcast(5, "drone.move(0,0,-"..anzahl..")")
else if direction == "u" then
m.broadcast(5, "drone.move(0,"..anzahl..",0)")
else if direction == "dd" then
m.broadcast(5, "drone.move(0,-"..anzahl..",0)")
else if direction == "rce" then
lin = io.read()
m.broadcast(5, lin)
else if direction == "use" then
m.broadcast(5, "drone.use("..anzahl..")")
end
end
end
end
end
end
end
end
end
ex = false
while ex == false do
round = 0
anzahl = 1
line = io.read()
if line == "exit" then
ex = true
else
mover()
end
end