Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local event = require("event")
- local sides = require("sides")
- local gpu = component.gpu
- gpu.setResolution(50,25)
- local left = component.proxy(component.get("3ba"))
- local mid = component.proxy(component.get("280"))
- local right = component.proxy(component.get("0cb"))
- local close = false
- local state = false
- gpu.setResolution(100,50)
- local w,h = gpu.getResolution()
- --Left - Floor
- --Mid - Door
- --Right - Corridor
- function opendoor()
- left.setOutput(sides.bottom, 15)
- right.setOutput(sides.bottom, 15)
- mid.setOutput(sides.bottom, 15)
- end
- function closedoor()
- mid.setOutput(sides.bottom, 0)
- left.setOutput(sides.bottom, 0)
- right.setOutput(sides.bottom, 0)
- end
- function button(_,_,_,_,_)
- if state == false then
- gpu.setBackground(0xcc0000)
- gpu.fill(1,1,w,h," ")
- closedoor()
- end
- if state == true then
- gpu.setBackground(0x00cc00)
- gpu.fill(1,1,w,h," ")
- opendoor()
- end
- if state == false then
- state = true
- elseif state == true then
- state = false
- end
- end
- function exit(_,_,_,z,_)
- if z == 207 then
- event.ignore("key_down", exit)
- event.ignore("touch", button)
- close = true
- end
- end
- event.listen("touch", button)
- event.listen("key_down", exit)
- button()
- while true do
- if close == true then
- break
- end
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement