SHOW:
|
|
- or go back to the newest paste.
1 | - | -- robot pulls the lever for the harvester |
1 | + | -- Quick & dirty menu for robot programs |
2 | - | -- starts with harvester off and empty |
2 | + | |
3 | -- pastebin -f get jCWcVYUz myMenu | |
4 | - | -- pastebin -f get CrLB3qKH rHarvest |
4 | + | |
5 | local robot = require("robot") | |
6 | local computer = require("computer") | |
7 | local term = require("term") | |
8 | ||
9 | local tArgs = { ... } | |
10 | local x = tArgs[1] | |
11 | ||
12 | -- print usage info if no tArg was specified but needed | |
13 | - | function refuel() |
13 | + | |
14 | - | robot.up() |
14 | + | term.clear() |
15 | - | robot.turnRight() |
15 | + | -- term.setCursor(column, row) |
16 | - | for i = 1, 11 do |
16 | + | term.setCursor(15, 4) |
17 | - | robot.forward() |
17 | + | term.write("Welcome to K9's Menu") |
18 | ||
19 | - | robot.turnLeft() |
19 | + | term.setCursor(8, 6) |
20 | - | robot.forward() |
20 | + | term.write("1 mySeeds (collects essence from plants)") |
21 | - | robot.forward() |
21 | + | |
22 | - | os.sleep(10) |
22 | + | term.setCursor(8, 8) |
23 | - | robot.turnAround() |
23 | + | term.write("0 exit this menu") |
24 | - | robot.forward() |
24 | + | |
25 | - | robot.forward() |
25 | + | term.setCursor(8, 10) |
26 | - | robot.turnRight() |
26 | + | term.write("Please enter the number of the program") |
27 | - | for i = 1, 11 do |
27 | + | |
28 | - | robot.forward() |
28 | + | |
29 | term.setCursor(8, 12) | |
30 | - | robot.turnRight() |
30 | + | x = tonumber(io.read()) |
31 | - | robot.down() |
31 | + | |
32 | if x == 1 then | |
33 | -- term.write("are you sure?") | |
34 | - | refuel() |
34 | + | term.write("Loading...") |
35 | os.sleep(2) | |
36 | - | while true do |
36 | + | term.clear() |
37 | - | print ("Starting to harvest crops") |
37 | + | os.execute("cd /home") |
38 | - | robot.use() -- switch on |
38 | + | os.execute("/home/mySeeds") |
39 | - | os.sleep(900) -- assuming that it takes 15 minutes to fill the harvester |
39 | + | |
40 | - | robot.use() -- switch off |
40 | + | if x == 0 then |
41 | - | print("Dumping to the chest") |
41 | + | -- term.write("are you sure?") |
42 | - | -- check fuel state |
42 | + | term.write("Exiting...") |
43 | - | if computer.energy() < 2500 then |
43 | + | os.sleep(2) |
44 | - | refuel() |
44 | + | term.clear() |
45 | - | end |
45 | + | os.execute("cd /home") |
46 | - | os.sleep(360) -- waits 6 minutes to empty harvester |
46 | + | return |
47 | end |