Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Door lock client by Totoro
- -- 15.07.2014
- port = 27
- local event = require('event')
- local serial = require('serialization')
- local sides = require('sides')
- local com = require('component')
- local modem = com.modem
- local gpu = com.gpu
- local redstone = com.redstone
- gpu.setResolution(14,7)
- width, height = gpu.getResolution()
- function square(color)
- gpu.fill(1, 1, width, height, ' ')
- gpu.setBackground(color)
- gpu.fill(3, 2, width-4, height-2, ' ')
- gpu.setBackground(0x000000)
- gpu.set(6,4, "Push")
- end
- function openLock()
- redstone.setOutput(sides.down, 15)
- os.sleep(1)
- redstone.setOutput(sides.down, 0)
- end
- square(0x005000)
- modem.open(port)
- while true do
- name, address, a, b, c, username, e = event.pull()
- if name == "key_down" then
- break
- elseif name == "touch" then
- modem.broadcast(port, serial.serialize({"lock", username}))
- elseif name == "modem_message" then
- if username == "lock_open" then
- openLock()
- elseif username == "lock_deny" then
- square(0xFF0000)
- os.sleep(0.8)
- square(0x005000)
- end
- else --print(name)
- end
- end
- gpu.setResolution(80,24)
- gpu.fill(1, 1, 80, 24, ' ')
- modem.close(port)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement