SHOW:
|
|
- or go back to the newest paste.
1 | - | --Pastebin code: Eps1arN4 |
1 | + | --Pastebin code: 9L63zjmY |
2 | ||
3 | - | --local bundleSide = "right" |
3 | + | local bundleSide = "right" |
4 | - | local modem = peripheral.wrap("top") |
4 | + | |
5 | local mX, mY = mon.getSize() | |
6 | mon.setTextScale(1) | |
7 | mon.setTextColor(colors.white) | |
8 | local button={} | |
9 | mon.setBackgroundColor(colors.black) | |
10 | ||
11 | - | liftControl = 32 |
11 | + | --moves lift one block |
12 | function Move( col ) | |
13 | rs.setBundledOutput(bundleSide, col) | |
14 | - | function MoveUp( dist ) |
14 | + | sleep(0.1) |
15 | - | rednet.send(liftControl, "up") |
15 | + | rs.setBundledOutput(bundleSide, 0) |
16 | - | local id, message, distance = rednet.receive(5) |
16 | + | sleep(0.9) |
17 | - | if id == liftControl then |
17 | + | |
18 | - | if message == "ok" then |
18 | + | |
19 | - | rednet.send(liftControl, tostring(dist)) |
19 | + | |
20 | - | id, message, distance = rednet.receive() |
20 | + | |
21 | - | end |
21 | + | |
22 | - | end |
22 | + | |
23 | if y>=data["ymin"] and y <= data["ymax"] then | |
24 | if x>=data["xmin"] and x<= data["xmax"] then | |
25 | - | function MoveDown() |
25 | + | |
26 | - | rednet.send(liftControl, "down") |
26 | + | |
27 | - | local id, message, distance = rednet.receive(5) |
27 | + | |
28 | - | if id == liftControl then |
28 | + | |
29 | - | if message == "ok" then |
29 | + | |
30 | - | rednet.send(liftControl, tostring(dist)) |
30 | + | |
31 | - | id, message, distance = rednet.receive() |
31 | + | |
32 | - | end |
32 | + | |
33 | - | end |
33 | + | |
34 | end | |
35 | ||
36 | function fill(text, color, bData) | |
37 | mon.setBackgroundColor(color) | |
38 | local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2) | |
39 | local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1 | |
40 | for j = bData["ymin"], bData["ymax"] do | |
41 | mon.setCursorPos(bData["xmin"], j) | |
42 | if j == yspot then | |
43 | for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do | |
44 | if k == xspot then | |
45 | mon.write(text) | |
46 | else | |
47 | mon.write(" ") | |
48 | end | |
49 | end | |
50 | else | |
51 | - | end |
51 | + | |
52 | mon.write(" ") | |
53 | end | |
54 | end | |
55 | end | |
56 | mon.setBackgroundColor(colors.black) | |
57 | end | |
58 | ||
59 | function CreateButton(name, func, minX, minY, maxX, maxY) | |
60 | button[name] = {} | |
61 | button[name]["func"] = func | |
62 | button[name]["active"] = false | |
63 | button[name]["xmin"] = minX | |
64 | button[name]["ymin"] = minY | |
65 | button[name]["xmax"] = maxX | |
66 | button[name]["ymax"] = maxY | |
67 | end | |
68 | ||
69 | function SetUpButtons() | |
70 | --CreateButton("Sec", Top, 3, 2, 5, 2) | |
71 | CreateButton("B", Basement, 2, 11, 3, 11) | |
72 | CreateButton("LB", LowerBasement, 5, 11, 6, 11) | |
73 | ||
74 | end | |
75 | ||
76 | function Screen() | |
77 | local currColor | |
78 | for name,data in pairs(button) do | |
79 | local on = data["active"] | |
80 | if on == true then | |
81 | currColor = colors.lime | |
82 | else currColor = colors.red | |
83 | end | |
84 | ||
85 | fill(name, currColor, data) | |
86 | end | |
87 | - | CreateButton("Sec", Top, 3, 2, 5, 3) |
87 | + | |
88 | - | CreateButton("B", Basement, 2, 11, 3, 12) |
88 | + | |
89 | - | CreateButton("LB", LowerBasement, 5, 11, 6, 12) |
89 | + | |
90 | - | CreateButton("G", Ground, 2, 9, 3, 10) |
90 | + | |
91 | - | CreateButton("1", FirstFloor, 5, 9, 6, 10) |
91 | + | |
92 | ||
93 | SetUpButtons() | |
94 | while true do | |
95 | - | function MoveLift(level) |
95 | + | |
96 | - | local x, z, y = gps.locate() |
96 | + | |
97 | - | print("destination.."..level) |
97 | + | |
98 | - | print("start.."..y) |
98 | + | |
99 | - | if y == level then |
99 | + | |
100 | - | --do nothing as on right floor |
100 | + | |
101 | - | elseif y < level then |
101 | + | |
102 | - | --while y ~= level do |
102 | + |