SHOW:
|
|
- or go back to the newest paste.
1 | write('Please enter the bot\'s id: ') | |
2 | - | bot = tonumber(read()) -- ask for the ID of the turtle |
2 | + | bot = tonumber(read()) -- the ID of the turtle |
3 | ||
4 | shell.run('clear') --clear the screen | |
5 | ||
6 | mode = 0 -- set the mode to dig | |
7 | rednet.open('right') -- open wifi port | |
8 | while true do -- start infinite loop | |
9 | event, key = os.pullEvent() -- wait for input | |
10 | - | if key == 208 then --if the down button is pressed |
10 | + | |
11 | - | rednet.send(bot, 'down')-- send message for down button |
11 | + | if key == 's' then --if the s button is pressed |
12 | rednet.send(bot, 'backward')-- send message for down button | |
13 | print('Backward') -- write on the screen | |
14 | - | if key == 203 then -- left |
14 | + | |
15 | if key == 'a' then -- left | |
16 | rednet.send(bot, 'left') | |
17 | print('Left') | |
18 | - | if key == 200 then --up |
18 | + | |
19 | if key == 'w' then --up | |
20 | rednet.send(bot, 'forward') | |
21 | print('Forward') | |
22 | - | if key == 205 then -- right |
22 | + | |
23 | if key == 'd' then -- right | |
24 | rednet.send(bot, 'right') | |
25 | print('Right') | |
26 | end | |
27 | if key == 200 then | |
28 | rednet.send(bot, 'up') | |
29 | print('Up') | |
30 | end | |
31 | if key == 208 then | |
32 | rednet.send(bot, 'down') | |
33 | print('Down') | |
34 | end | |
35 | - | if key == 201 then --if the key is PageUp (cause i like that) |
35 | + | |
36 | if key == ' ' then --if the key is the spacebar | |
37 | if mode == 0 then -- if on digmode | |
38 | rednet.send(bot, 'dig') -- send message to dig | |
39 | - | if key == 209 then -- if PageDown |
39 | + | |
40 | elseif mode == 1 then -- if on placemode | |
41 | rednet.send(bot, 'place') -- send message to place block | |
42 | print('Place') --write | |
43 | - | if key == 157 then --if ctrl is pressed |
43 | + | |
44 | end | |
45 | if key == 203 then --if the key is left | |
46 | mode = 0 -- set to digmode | |
47 | print('Dig mode selected.') --write it | |
48 | end | |
49 | if key == 205 then -- if right | |
50 | mode = 1 -- set to placemode | |
51 | print('Place mode selected.') --write | |
52 | end | |
53 | if key == 29 then --if the left ctrl is pressed | |
54 | rednet.send(bot, 'rs') -- send message to enable redstone | |
55 | print('Redstone activated.')-- write | |
56 | end | |
57 | end |