Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.find("monitor")
- rednet.open("right")
- cablePos = "bottom"
- etage = "ETAGE -2"
- dyh = 8
- dyb = 0
- bg = colors.white
- text = colors.gray
- function windowInit(win, bgColor, cursorX, cursorY, text)
- win.setBackgroundColor(bgColor)
- win.clear()
- win.setCursorPos(cursorX, cursorY)
- win.write(text)
- end
- function monInit()
- mon.setBackgroundColor(bg)
- mon.setTextColor(text)
- mon.clear()
- mon.setTextScale(0.5)
- mon.setCursorPos(5,1)
- mon.write(etage)
- if dyh>0 then
- up = window.create(mon, 2, 3, 13, 10)
- windowInit(up, colors.lightBlue, 4, 5, "ETAGE -1")
- end
- if dyb>0 then
- down = window.create(mon, 2, 14, 13, 10)
- windowInit(down, colors.orange, 4, 5, "")
- end
- end
- function move(slp, dy, color)
- local i = 0
- while i<dy do
- rs.setBundledOutput(cablePos, color)
- sleep(slp)
- rs.setBundledOutput(cablePos, 0)
- sleep(slp)
- i = i+1
- end
- end
- function touchedWindow(win, ex, ey)
- local x, y = win.getPosition()
- return ((ex>=x) and (ex<=x+12) and (ey>=y) and (ey<=y+9))
- end
- function touchedButton(win)
- win.setBackgroundColor(bg)
- win.clear()
- win.setVisible(false)
- end
- monInit()
- while true do
- local e, p1, p2, p3 = os.pullEvent()
- if e=="monitor_touch" then
- x = p2
- y = p3
- if (up~=nil) and touchedWindow(up, x, y) then
- rednet.broadcast("elevator_right")
- touchedButton(up)
- move(0.4, dyh, colors.blue)
- rednet.broadcast("", "elevator_right")
- os.reboot()
- end
- if (down~=nil) and touchedWindow(down, x, y) then
- rednet.broadcast("elevator_right")
- touchedButton(down)
- move(0.4, dyb, colors.orange)
- rednet.broadcast("", "elevator_right")
- os.reboot()
- end
- elseif e=="rednet_message" then
- msg = p2
- if msg=="elevator_right" then
- if up~=nil then touchedButton(up) end
- if down~=nil then touchedButton(down) end
- rednet.receive("elevator_right", 10)
- os.reboot()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement