Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SOrd={"top","bottom","left","right","front","back"}
- local SDet,state,cLr={},nil,0,{colors.gray,colors.gray}
- local backMon, leftMon, rightMon
- showText = true
- local function default()
- leftMon.setCursorPos(1,10)
- leftMon.setBackgroundColor(cLr[2])
- leftMon.clear()
- leftMon.write("Ready?")
- rightMon.setCursorPos(1,10)
- rightMon.setBackgroundColor(cLr[2])
- rightMon.clear()
- rightMon.write("Ready?")
- backMon.setBackgroundColor(colors.red)
- backMon.setCursorPos(2,2)
- backMon.clear()
- end
- local function ready()
- leftMon.setCursorPos(1,10)
- leftMon.setBackgroundColor(colors.yellow)
- leftMon.setTextColor(colors.black)
- leftMon.clear()
- leftMon.write("Ready")
- rightMon.setCursorPos(1,10)
- rightMon.setBackgroundColor(colors.yellow)
- rightMon.setTextColor(colors.black)
- rightMon.clear()
- rightMon.write("Ready")
- backMon.setBackgroundColor(colors.yellow)
- backMon.setTextColor(colors.black)
- backMon.setCursorPos(2,1.5)
- backMon.clear()
- if showText then
- backMon.setTextScale(4)
- backMon.write("Ready")
- end
- end
- local function go()
- rs.setOutput("bottom",true)
- sleep(8)
- rs.setOutput("bottom",false)
- sleep(8)
- rednet.send(HID,"reset")
- leftMon.setCursorPos(1,10)
- leftMon.setBackgroundColor(colors.lime)
- leftMon.setTextColor(colors.black)
- leftMon.clear()
- leftMon.write("Go!")
- rightMon.setCursorPos(1,10)
- rightMon.setBackgroundColor(colors.lime)
- rightMon.setTextColor(colors.black)
- rightMon.clear()
- rightMon.write("Go!")
- backMon.setBackgroundColor(colors.lime)
- backMon.setCursorPos(3,1.5)
- backMon.clear()
- if showText then
- backMon.setTextScale(4)
- backMon.write("Go!")
- end
- end
- local function setup()
- state = 0
- print("ID:",os.getComputerID())
- if not fs.exists("txt") then
- write("Host ID:")
- local input=read()
- local h=fs.open("txt","w")
- h.write("HID,cLr=")
- h.write(input)
- h.writeLine(",{colors.green,colors.red}")
- h.close()
- end
- term.clear()
- term.setCursorPos(1,1)
- os.loadAPI("txt")
- HID=txt.HID
- if term.isColor() then
- cLr=txt.cLr
- print("Advanced PC")
- else
- print("Normal PC")
- end
- os.unloadAPI("txt")
- print("Host ID: "..HID)
- print("This ID:",os.getComputerID())
- for i=1,6 do
- if peripheral.isPresent(SOrd[i]) then
- SDet[i]=peripheral.getType(SOrd[i])
- if SDet[i]=="monitor" then
- if peripheral.call(SOrd[i],"isColor") then
- SDet[i]="monitor+"
- if backMon==nil then
- backMon=peripheral.wrap("back")
- end
- if leftMon==nil then
- leftMon=peripheral.wrap("left")
- end
- if rightMon==nil then
- rightMon=peripheral.wrap("right")
- end
- end
- elseif SDet[i]=="modem" then
- rednet.open(SOrd[i])
- state=state+1
- end
- end
- print(SOrd[i],"|",SDet[i])
- end
- term.setTextColor(cLr[1])
- if backMon==nil or leftMon==nil or rightMon==nil then
- term.setTextColor(cLr[2])
- write("No ")
- end
- print("Advanced Monitor Detected (Required)")
- term.setTextColor(cLr[1])
- if state==0 then
- term.setTextColor(cLr[2])
- write("No ")
- end
- print("Modem Detected (Required)")
- if backMon==nil or leftMon==nil or rightMon==nil or state==0 then
- return
- end
- print("Use monitor to continue")
- state=0
- rednet.send(HID,"register")
- end
- local function main()
- setup()
- while true do
- leftMon.setBackgroundColor(colors.black)
- leftMon.clear() leftMon.setCursorPos(1,1)
- if state==0 then
- default()
- elseif state==1 then
- ready()
- end
- event,x,y,z = os.pullEvent()
- if event == "monitor_touch" and state < 2 then
- if state == 0 then
- rednet.send(HID,"ready")
- state = 1
- else
- rednet.send(HID,"unready")
- state = 0
- end
- elseif event == "rednet_message" then
- id = x
- message = y
- print(event,"|",id,"|",message)
- if message == "reset" then
- state = 0
- elseif message == "go" then
- go()
- end
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement