SHOW:
|
|
- or go back to the newest paste.
1 | local SOrd={"top","bottom","left","right","front","back"} | |
2 | local SDet,state,cLr={},nil,0,{colors.gray,colors.gray} | |
3 | ||
4 | local backMon, leftMon, rightMon | |
5 | ||
6 | showText = true | |
7 | ||
8 | local function default() | |
9 | redstone.setOutput("bottom", false) | |
10 | leftMon.setCursorPos(1,10) | |
11 | leftMon.setBackgroundColor(cLr[2]) | |
12 | leftMon.clear() | |
13 | leftMon.write("Ready?") | |
14 | ||
15 | rightMon.setCursorPos(1,10) | |
16 | rightMon.setBackgroundColor(cLr[2]) | |
17 | rightMon.clear() | |
18 | rightMon.write("Ready?") | |
19 | ||
20 | backMon.setBackgroundColor(colors.red) | |
21 | backMon.setCursorPos(2,2) | |
22 | backMon.clear() | |
23 | end | |
24 | ||
25 | local function ready() | |
26 | leftMon.setCursorPos(1,10) | |
27 | leftMon.setBackgroundColor(colors.yellow) | |
28 | leftMon.setTextColor(colors.black) | |
29 | leftMon.clear() | |
30 | leftMon.write("Ready") | |
31 | ||
32 | rightMon.setCursorPos(1,10) | |
33 | rightMon.setBackgroundColor(colors.yellow) | |
34 | rightMon.setTextColor(colors.black) | |
35 | rightMon.clear() | |
36 | rightMon.write("Ready") | |
37 | ||
38 | backMon.setBackgroundColor(colors.yellow) | |
39 | backMon.setTextColor(colors.black) | |
40 | backMon.setCursorPos(2,1.5) | |
41 | backMon.clear() | |
42 | if showText then | |
43 | backMon.setTextScale(4) | |
44 | backMon.write("Ready") | |
45 | end | |
46 | end | |
47 | ||
48 | local function go() | |
49 | turtle.digDown() | |
50 | turtle.suckDown() | |
51 | turtle.placeDown() | |
52 | ||
53 | rs.setOutput("bottom", true) | |
54 | ||
55 | leftMon.setCursorPos(1,10) | |
56 | leftMon.setBackgroundColor(colors.lime) | |
57 | leftMon.setTextColor(colors.black) | |
58 | leftMon.clear() | |
59 | leftMon.write("Go!") | |
60 | ||
61 | rightMon.setCursorPos(1,10) | |
62 | rightMon.setBackgroundColor(colors.lime) | |
63 | rightMon.setTextColor(colors.black) | |
64 | rightMon.clear() | |
65 | rightMon.write("Go!") | |
66 | ||
67 | backMon.setBackgroundColor(colors.lime) | |
68 | backMon.setCursorPos(3,1.5) | |
69 | backMon.clear() | |
70 | if showText then | |
71 | backMon.setTextScale(4) | |
72 | backMon.write("Go!") | |
73 | end | |
74 | ||
75 | os.sleep(8) | |
76 | redstone.setOutput("bottom",false) | |
77 | ||
78 | state = 0 | |
79 | end | |
80 | ||
81 | local function setup() | |
82 | state = 0 | |
83 | ||
84 | print("ID:",os.getComputerID()) | |
85 | ||
86 | if not fs.exists("txt") then | |
87 | write("Host ID:") | |
88 | local input=read() | |
89 | local h=fs.open("txt","w") | |
90 | h.write("HID,cLr=") | |
91 | h.write(input) | |
92 | h.writeLine(",{colors.green,colors.red}") | |
93 | h.close() | |
94 | end | |
95 | ||
96 | term.clear() | |
97 | term.setCursorPos(1,1) | |
98 | ||
99 | os.loadAPI("txt") | |
100 | HID=txt.HID | |
101 | if term.isColor() then | |
102 | cLr=txt.cLr | |
103 | print("Advanced PC") | |
104 | else | |
105 | print("Normal PC") | |
106 | end | |
107 | ||
108 | os.unloadAPI("txt") | |
109 | ||
110 | print("Host ID: "..HID) | |
111 | print("This ID:",os.getComputerID()) | |
112 | ||
113 | for i=1,6 do | |
114 | if peripheral.isPresent(SOrd[i]) then | |
115 | SDet[i]=peripheral.getType(SOrd[i]) | |
116 | if SDet[i]=="monitor" then | |
117 | if peripheral.call(SOrd[i],"isColor") then | |
118 | SDet[i]="monitor+" | |
119 | if backMon==nil then | |
120 | - | backMon=peripheral.wrap("back") |
120 | + | backMon=peripheral.wrap("left") |
121 | end | |
122 | ||
123 | if leftMon==nil then | |
124 | - | leftMon=peripheral.wrap("left") |
124 | + | leftMon=peripheral.wrap("back") |
125 | end | |
126 | ||
127 | if rightMon==nil then | |
128 | rightMon=peripheral.wrap("front") | |
129 | end | |
130 | end | |
131 | elseif SDet[i]=="modem" then | |
132 | rednet.open(SOrd[i]) | |
133 | state=state+1 | |
134 | end | |
135 | end | |
136 | print(SOrd[i],"|",SDet[i]) | |
137 | end | |
138 | ||
139 | term.setTextColor(cLr[1]) | |
140 | if backMon==nil or leftMon==nil or rightMon==nil then | |
141 | term.setTextColor(cLr[2]) | |
142 | write("No ") | |
143 | end | |
144 | ||
145 | print("Advanced Monitor Detected (Required)") | |
146 | ||
147 | term.setTextColor(cLr[1]) | |
148 | if state==0 then | |
149 | term.setTextColor(cLr[2]) | |
150 | write("No ") | |
151 | end | |
152 | ||
153 | print("Modem Detected (Required)") | |
154 | ||
155 | if backMon==nil or leftMon==nil or rightMon==nil or state==0 then | |
156 | return | |
157 | end | |
158 | ||
159 | print("Use monitor to continue") | |
160 | ||
161 | state=0 | |
162 | rednet.send(HID,"register") | |
163 | end | |
164 | ||
165 | local function main() | |
166 | ||
167 | setup() | |
168 | ||
169 | while true do | |
170 | leftMon.setBackgroundColor(colors.black) | |
171 | leftMon.clear() leftMon.setCursorPos(1,1) | |
172 | ||
173 | if state==0 then | |
174 | default() | |
175 | elseif state==1 then | |
176 | ready() | |
177 | end | |
178 | ||
179 | event,x,y,z = os.pullEvent() | |
180 | ||
181 | if event == "rednet_message" then | |
182 | id = x | |
183 | message = y | |
184 | ||
185 | print(event,"|",id,"|",message) | |
186 | if message == "go" then | |
187 | go() | |
188 | end | |
189 | elseif event == "monitor_touch" and state < 2 then | |
190 | if state == 0 then | |
191 | rednet.send(HID,"ready") | |
192 | state = 1 | |
193 | else | |
194 | rednet.send(HID,"unready") | |
195 | state = 0 | |
196 | end | |
197 | end | |
198 | end | |
199 | end | |
200 | ||
201 | main() |