Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- peri = fs.open("periph","r")
- a1 = peri.readLine()
- a2 = peri.readLine()
- peri.close()
- p1 = peripheral.wrap(a1)
- p2 = peripheral.wrap(a2)
- function color(e1,e2)
- e1.setBackgroundColor(e2)
- e1.clear()
- end
- function contr(r1,r2,p1,p2,astat)
- print(r1)
- print(r2)
- print(rs.getInput("left"))
- print(rs.getInput("right"))
- if r2 == rs.getInput("left") or r1 == rs.getInput("right") then
- rs.setOutput("left",not r1)
- rs.setOutput("right",not r2)
- if r1 then
- color(p1,colors.green)
- color(p2,colors.red)
- elseif r2 then
- color(p1,colors.red)
- color(p2,colors.green)
- else
- color(p1,colors.orange)
- color(p2,colors.orange)
- end
- end
- end
- mon = peripheral.wrap("back")
- for y = 1,12 do
- for x = 1,29 do
- if x > 20 or x < 10 then
- mon.setBackgroundColor(colors.green)
- else
- mon.setBackgroundColor(colors.red)
- end
- mon.setCursorPos(x,y)
- mon.write(" ")
- end
- end
- while true do
- e,d1,x,y = os.pullEvent()
- if e == "timer" and tn == d1 then
- astat = contr(false,false,p1,p2,astat)
- end
- if d1 == "monitor_1" then
- astat = contr(true,false,p1,p2,astat)
- tn = os.startTimer(10)
- end
- if d1 == "monitor_0" then
- astat = contr(false,true,p1,p2,astat)
- tn = os.startTimer(10)
- end
- if d1 == "back" then
- if x < 10 then
- astat = contr(false,true,p1,p2,astat)
- tn = os.startTimer(10)
- elseif x > 19 then
- astat = contr(true,false,p1,p2,astat)
- tn = os.startTimer(10)
- else
- astat = contr(false,false,p1,p2,astat)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement