SHOW:
|
|
- or go back to the newest paste.
1 | shell.run("clear") | |
2 | os.loadAPI("ocs/apis/sensor") | |
3 | mon = peripheral.wrap("front") | |
4 | mon.clear() | |
5 | mon.setTextScale(0.5) | |
6 | rs.setOutput("left",false) | |
7 | rs.setOutput("right",false) | |
8 | sleep(0.5) | |
9 | sen = sensor.wrap("bottom") | |
10 | gx,gy = mon.getSize() | |
11 | while true do | |
12 | s = sen.getTargets() | |
13 | yx = 2 | |
14 | mon.clear() | |
15 | f = 0 | |
16 | ||
17 | for v,k in pairs(s) do | |
18 | s1 = sen.getTargetDetails(v) | |
19 | ||
20 | ||
21 | ||
22 | x = s1.Position.X | |
23 | y = s1.Position.Y | |
24 | z = s1.Position.Z | |
25 | mon.setCursorPos(2,yx) | |
26 | mon.write(v) | |
27 | mon.setCursorPos(18,yx) | |
28 | mon.write("X: " .. string.format("%d",x)) | |
29 | mon.setCursorPos(24,yx) | |
30 | mon.write("Y: " .. string.format("%d",y)) | |
31 | mon.setCursorPos(30,yx) | |
32 | mon.write("Z: " .. string.format("%d",z)) | |
33 | ||
34 | if x < 3 and x > -3 and z > -12 and z < 8 then | |
35 | f = f + 1 | |
36 | n = "INSIDE" | |
37 | else | |
38 | n = "OUTSIDE" | |
39 | end | |
40 | mon.setCursorPos(36,yx) | |
41 | mon.write("Position: " .. n) | |
42 | mon.setCursorPos(54,yx) | |
43 | mon.write("Held Item: " .. s1.HeldItem.Name) | |
44 | yx = yx + 1 | |
45 | end | |
46 | ||
47 | if f == 0 then | |
48 | for b = 1,3,1 do | |
49 | rs.setOutput("right",true) | |
50 | sleep(0.5) | |
51 | rs.setOutput("right",false) | |
52 | sleep(0.5) | |
53 | ||
54 | --mon.setCursorPos(gx-5,gy) | |
55 | --mon.write("CLOSE") | |
56 | end | |
57 | else | |
58 | for b = 1,3,1 do | |
59 | rs.setOutput("left",true) | |
60 | sleep(0.5) | |
61 | rs.setOutput("left",false) | |
62 | sleep(0.5) | |
63 | --mon.setCursorPos(gx-5,gy) | |
64 | --mon.write("OPEN") | |
65 | end | |
66 | sleep(0.5) | |
67 | end | |
68 | end |