Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = require("term")
- local component = require("component")
- local sides = require("sides")
- local rs = component.redstone
- local colors = require("colors")
- local gpu = component.gpu
- local screen = component.screen
- local event = require("event")
- os.sleep(0.2)
- local gpus = {}
- local screens = {}
- for address, filter in component.list("gpu") do
- table.insert(gpus,address)
- end
- for address, filter in component.list("screen") do
- table.insert(screens,address)
- end
- local gpu1 = component.proxy(gpus[1])
- local gpu2 = component.proxy(gpus[2])
- gpu1.bind(screens[1], true)
- gpu2.bind(screens[2],true)
- --[[
- gpu1.setResolution(20,5)
- gpu2.setResolution(20,5)
- ]]
- component.proxy(screens[1]).setTouchModeInverted(true)
- component.proxy(screens[2]).setTouchModeInverted(true)
- function getScreenWidth(gpuz)
- local x,y = gpuz.getResolution()
- return x;
- end
- function getScreenHeight(gpuz)
- local x,y = gpuz.getResolution()
- return y;
- end
- function clearScreen()
- gpu1.fill(1,1,getScreenWidth(gpu1),getScreenHeight(gpu1),' ')
- gpu1.setForeground(0xFFFFFF)
- gpu2.fill(1,1,getScreenWidth(gpu2),getScreenHeight(gpu2),' ')
- gpu2.setForeground(0xFFFFFF)
- gpu1.fill(2,2,getScreenWidth(gpu1)-2,getScreenHeight(gpu1)-2,'|')
- gpu1.setForeground(0x00FF00)
- gpu1.set((getScreenWidth(gpu2)/2)-1,(getScreenHeight(gpu1)/2)+1,"OPEN")
- gpu2.fill(2,2,getScreenWidth(gpu2)-2,getScreenHeight(gpu2)-2,'|')
- gpu2.setForeground(0x00FF00)
- gpu2.set((getScreenWidth(gpu2)/2)-1,(getScreenHeight(gpu2)/2)+1,"OPEN")
- end
- function hasAccess(username)
- local occurences = 0
- local users = {"csmajor","G_Dog1985_"}
- for i=1,#users do
- if users[i] == username then
- occurences = occurences+1
- end
- if occurences > 1 then
- clearScreen()
- gpu1.setForeground(0xFF0000)
- gpu1.set(1,1,"DATABASE:Data > 1")
- gpu2.setForeground(0xFF0000)
- gpu2.set(1,1,"DATABASE:Data > 1")
- os.sleep(1)
- return false
- elseif occurences == 1 then
- return true
- end
- end
- return false
- end
- function isRemoteAccess(message)
- for i,code in message do
- print(code)
- end
- end
- function eventModemMessage(eventName, localAddress, remoteAddress, port, distance, messages)
- for i,code in pairs(messages) do
- print(code)
- end
- --[[if isRemoteAccess(messages) then
- gpu1.set((getScreenWidth(gpu1)/2)-3,(getScreenHeight(gpu1)/2)+1,"GRANTED")
- gpu2.set((getScreenWidth(gpu2)/2)-3,(getScreenHeight(gpu2)/2)+1,"GRANTED")
- rs.setOutput(sides.bottom,15)
- os.sleep(2)
- rs.setOutput(sides.bottom,0)
- clearScreen()
- end]]
- end
- event.listen("modem_message",eventModemMessage)
- local open = false
- function access(eventName,ip,x,y,button,playerName)
- clearScreen()
- if open == false then
- open = true
- if(playerName ~= nil) then
- if(hasAccess(playerName)) then
- gpu1.set((getScreenWidth(gpu1)/2)-3,(getScreenHeight(gpu1)/2)+1,"GRANTED")
- gpu2.set((getScreenWidth(gpu2)/2)-3,(getScreenHeight(gpu2)/2)+1,"GRANTED")
- rs.setOutput(sides.bottom,15)
- os.sleep(3)
- rs.setOutput(sides.bottom,0)
- else
- gpu1.setForeground(0xFF0000)
- gpu1.set((getScreenWidth(gpu1)/2)-3,(getScreenHeight(gpu1)/2)+1,"DENIED")
- gpu2.setForeground(0xFF0000)
- gpu2.set((getScreenWidth(gpu2)/2)-3,(getScreenHeight(gpu2)/2)+1,"DENIED")
- os.sleep(2)
- end
- end
- end
- clearScreen()
- open = false
- end
- event.listen("touch",access)
- access()
Advertisement
Add Comment
Please, Sign In to add comment