Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Initalization
- term.setTextColor(colors.lime)
- term.setBackgroundColor(colors.gray)
- shell.run('clear')
- term.clear()
- print("RedHouse V0.1 by JMZ10")
- print(" ")
- sleep(1)
- repeat
- io.write("Desktop or PDA [D/P]? ")
- io.flush()
- answer=io.read()
- until answer == "d" or answer == "p"
- if answer == "p" then
- rednet.open("back")
- else
- rednet.open("top")
- end
- --Server Mode Display Text
- function serverText()
- term.setTextColor(colors.blue)
- term.setBackgroundColor(colors.white)
- shell.run('clear')
- term.clear()
- print("RedHouse V0.1 by JMZ10")
- end
- --Rednet Reciever Code
- function DoorServer()
- serverText()
- print("Running as a Door Server")
- print("To Turn off Server Press & Hold Ctrl + R ")
- print("- - -")
- while true do
- message = rednet.recieve()
- if message == "DR1" then
- redstone.setOutput("back", true)
- sleep(2)
- redstone.setOutput("back", false)
- end
- end
- end
- redIO = 0
- function LightServer()
- serverText()
- print("Running as a Light Server")
- print("To Turn off Server Press & Hold Ctrl + R ")
- print("- - -")
- while true do
- local senderId, message, distance = rednet.receive()
- if message == "LCR1" then
- if redIO == 0 then
- redIO = 1
- redstone.setOutput("back", true)
- rednet.broadcast("MSGRS")
- else
- redIO = 0
- redstone.setOutput("back", false)
- rednet.broadcast("MSGRS")
- end
- end
- end
- end
- --Rednet Transmitter Code
- function DoorAccess()
- print("DT1")
- end
- function LightControl()
- rednet.broadcast("LCR1")
- sleep(1)
- local senderId, message, distance = rednet.receive(2)
- if message == "MGSRS" then
- print("Lights Toggled Successfully")
- else
- print("Lights Failed to Toggle!")
- end
- end
- --Determine Mode
- local answer
- repeat
- io.write("Server or Client [S/C]? ")
- io.flush()
- answer=io.read()
- until answer == "s" or answer == "c"
- shell.run('clear')
- print("RedHouse V0.1 by JMZ10")
- print(" ")
- --When Server Mode
- if answer == "s" then
- LightServer()
- -- repeat
- -- io.write("Lighting or Door[L/D]?")
- -- io.flush()
- -- answer=io.read()
- -- until answer == "l" or answer == "d"
- -- if answer == "l" then
- -- LightServer()
- -- elseif answer == "d" then
- -- DoorServer()
- -- end
- -- When Client Mode
- else
- LightControl()
- --repeat
- --io.write("Lighting or Door[L/D]: |")
- -- io.flush()
- -- answer=io.read()
- -- until answer == "l" or answer == "d"
- -- if answer == "l" then
- -- LightControl()
- -- elseif answer == "d" then
- -- DoorAccess()
- -- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement