Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- side = "bottom"
- password = "269723"
- decline = "Access Denied"
- approved_on = "Access Granted! Shield Online."
- approved_off = "Access Granted! Shield Offline."
- error_msg = "invalid entry"
- function run()
- term.setBackgroundColor(colors.gray)
- term.clear()
- term.setTextColor(colors.yellow)
- term.setCursorPos(1,1)
- term.write("Shield Server v1.0")
- term.setCursorPos(25,1)
- term.write("Shield Status: ")
- term.setCursorPos(1,2)
- term.write("==================")
- term.setCursorPos(1,4)
- term.write("Now Accepting Connection From:")
- while(true) do
- local id, message, protocol = rednet.receive()
- term.setTextColor(colors.red)
- term.write(id)
- local start_point = string.find(message, "<p>") + 3
- local end_point = string.find(message, "</p>") - 1
- local user_password = string.sub(message, start_point, end_point)
- local start_point = string.find(message, "<r>") + 3
- local end_point = string.find(message, "</r>") - 1
- local request = string.sub(message, start_point, end_point)
- if(user_password == password) then
- if(request == "on") then
- redstone.setOutput(side, true)
- rednet.send(id, approved_on)
- term.setCursorPos(40,1)
- term.setTextColor(colors.lime)
- term.write("ONLINE ")
- elseif(request == "off") then
- redstone.setOutput(side, false)
- rednet.send(id, approved_off)
- term.setCursorPos(40,1)
- term.setTextColor(colors.red)
- term.write("OFFLINE")
- else
- rednet.send(id, error_msg)
- end
- else
- rednet.send(id, decline)
- end
- term.clearLine()
- term.setCursorPos(1,5)
- end
- end
- run()
Advertisement
Add Comment
Please, Sign In to add comment