Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function logged()
- local menu_options = { --This is our menu table. It contains basic data about the menu
- [1] = {text="Check Log!", color=colors.lime},
- [2] = {text="Edit Log!", color=colors.lime},
- [3] = {text="Check Files!", color=colors.lime},
- [4] = {text="Disconnect!", color=colors.lime}
- }
- local termX, termY = term.getSize() --The x/y size of the terminal
- local function menuDraw(selected) --Our main draw function
- local yPos = termY/2 - #menu_options/2 --The initial y position
- for index, data in pairs(menu_options) do
- menu_options[index].bounds = { --Create a new table in each option with the boundary data
- x1 = termX/2 - (#data.text+4)/2;
- x2 = termX/2 + (#data.text+4)/2;
- y = yPos;
- }
- term.setTextColor(data.color)
- term.setCursorPos(data.bounds.x1, data.bounds.y)
- local text =
- index==selected and "[ "..data.text.." ]" or
- " "..data.text.." " --Essentially an if statement, but in a contracted form
- term.write(text)
- yPos = yPos+1 --Increment the initial y pos so we can move on the next line
- end
- end
- local function checkClick(x,y) --Check the mouse click to see if there's a menu option
- for index, data in pairs(menu_options) do
- if x>= data.bounds.x1 and x<= data.bounds.x2 and y==data.bounds.y then
- return index --Returns the index of the clicked option
- end
- end
- return false --If it went through the entire for loop without success, return false
- end
- term.setBackgroundColor(colors.white)
- term.clear()
- local selector = 1 --Our selector
- while true do --The main loop. I would generally put this inside of a function for a program.
- menuDraw(selector) --Draw the menu first
- local e = {os.pullEvent()} --Pull an event and put the returned values into a table
- if e[1] == "key" then --If it's a key...
- if e[2] == keys.down then -- ... and it's the down arrow
- selector = selector < #menu_options and selector+1 or 1 --Increment the selector if the selector < #menu_options. Otherwise reset it to 1
- elseif e[2] == keys.up then
- selector = selector > 1 and selector-1 or #menu_options --Decrement the selector if the selector > 1. Otherwise, reset it to #menu_options
- elseif e[2] == keys.enter then
- break --Break out of the loop
- end
- elseif e[1] == "mouse_click" then
- local value = checkClick(e[3], e[4]) --Check the mouse click
- if value then --If checkClick returns a value and not false
- selector = value --Set the selector to that value and break out of the loop
- break
- end
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- if selector == (1) then
- rednet.send(tonumber(Hack),"log")
- id,msg = rednet.receive()
- print(msg)
- print("Press any key to Continue!")
- io.read()
- logged()
- elseif selector == (2) then
- rednet.send(tonumber(Hack),"log")
- id,msg = rednet.receive()
- print(msg)
- print("Press any key to Edit!")
- io.read()
- term.clear()
- term.setCursorPos(1,1)
- print("Type done to Finish!")
- local file = fs.open("Elog","a")
- while true do
- input = io.read()
- if input == ("done") then
- break
- else
- file.writeLine(input)
- end
- end
- file.close()
- local file = fs.open("Elog","r")
- read = file.readAll()
- rednet.send(tonumber(Hack),"elog",tostring(read))
- file.close()
- local file = fs.open("Elog","w")
- file.write()
- file.close()
- logged()
- elseif selector == (3) then
- rednet.send(tonumber(Hack),"file")
- id,msg = rednet.receive()
- print(msg)
- print("Press any key to Continue!")
- io.read()
- logged()
- elseif selector == (4) then
- print("Disconnecting..")
- sleep(1)
- os.reboot()
- end
- end
- --Made by DEATHBYSH33P with bugfixing from 1lann
- term.setTextColor(colors.lime)
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- textutils.slowPrint("WatchLinkBETA")
- textutils.slowPrint("Made by deathbysh33p")
- sleep(1)
- os.loadAPI("specs")
- Enc = specs.Enc
- PC = specs.PasswordCracker
- shell.openTab("Red")
- function main()
- local menu_options = { --This is our menu table. It contains basic data about the menu
- [1] = {text="Rednet Log", color=colors.lime},
- [2] = {text="Info", color=colors.lime},
- [3] = {text="Hacked Ip's",color=colors.lime},
- [4] = {text="Scanned Ip's",color=colors.lime},
- [5] = {text="Scan for Devices",color=colors.lime},
- [6] = {text="Hack an IP",color=colors.lime},
- [7] = {text="Connect",color=colors.lime},
- [8] = {text="Bank",color=colors.lime}
- }
- local termX, termY = term.getSize() --The x/y size of the terminal
- local function menuDraw(selected) --Our main draw function
- local yPos = termY/2 - #menu_options/2 --The initial y position
- for index, data in pairs(menu_options) do
- menu_options[index].bounds = { --Create a new table in each option with the boundary data
- x1 = termX/2 - (#data.text+4)/2;
- x2 = termX/2 + (#data.text+4)/2;
- y = yPos;
- }
- term.setTextColor(data.color)
- term.setCursorPos(data.bounds.x1, data.bounds.y)
- local text =
- index==selected and "[ "..data.text.." ]" or
- " "..data.text.." " --Essentially an if statement, but in a contracted form
- term.write(text)
- yPos = yPos+1 --Increment the initial y pos so we can move on the next line
- end
- end
- local function checkClick(x,y) --Check the mouse click to see if there's a menu option
- for index, data in pairs(menu_options) do
- if x>= data.bounds.x1 and x<= data.bounds.x2 and y==data.bounds.y then
- return index --Returns the index of the clicked option
- end
- end
- return false --If it went through the entire for loop without success, return false
- end
- term.setBackgroundColor(colors.white)
- term.clear()
- local selector = 1 --Our selector
- while true do --The main loop. I would generally put this inside of a function for a program.
- menuDraw(selector) --Draw the menu first
- local e = {os.pullEvent()} --Pull an event and put the returned values into a table
- if e[1] == "key" then --If it's a key...
- if e[2] == keys.down then -- ... and it's the down arrow
- selector = selector < #menu_options and selector+1 or 1 --Increment the selector if the selector < #menu_options. Otherwise reset it to 1
- elseif e[2] == keys.up then
- selector = selector > 1 and selector-1 or #menu_options --Decrement the selector if the selector > 1. Otherwise, reset it to #menu_options
- elseif e[2] == keys.enter then
- break --Break out of the loop
- end
- elseif e[1] == "mouse_click" then
- local value = checkClick(e[3], e[4]) --Check the mouse click
- if value then --If checkClick returns a value and not false
- selector = value --Set the selector to that value and break out of the loop
- break
- end
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- if selector == (1) then
- local file = fs.open("log","r")
- read = file.readAll()
- print(read)
- file.close()
- print("Press any key to Continue")
- io.read()
- main()
- elseif selector == (2) then
- local file = fs.open("specs","r")
- read = file.readAll()
- print(read)
- print("Press any key to Continue")
- io.read()
- main()
- elseif selector == (3) then
- local file = fs.open("contacts","r")
- read = file.readAll()
- print(read)
- print("Press any Key to Continue")
- io.read()
- main()
- elseif selector == (4) then
- local file = fs.open("scanned","r")
- read = file.readAll()
- print(read)
- file.close()
- print("Press any key to Continue")
- io.read()
- main()
- elseif selector == (5) then
- rednet.broadcast("Scan")
- print("Scanning")
- id,msg = rednet.receive()
- print("ID Found!")
- sleep(1)
- local file = fs.open("scanned","a")
- file.writeLine(id)
- file.close()
- main()
- elseif selector == (6) then
- print("Enter the ID")
- Hack = read()
- print("Attempting to Crack ID's Password with")
- print("PasswordCracker lvl "..PC)
- if tonumber(Hack) == nil then
- sleep(1)
- print("Invalid ID")
- sleep(1)
- main()
- end
- rednet.send(tonumber(Hack),"PC",tonumber(PC))
- id,msg,msg2 = rednet.receive(5)
- if msg2 == ("success") then
- print(msg)
- local file = fs.open("contacts","a")
- file.writeLine(tonumber(Hack).." : "..tostring(msg))
- file.close()
- sleep(1)
- main()
- elseif msg2 == ("fail") then
- print(msg)
- sleep(1)
- main()
- elseif not id then
- sleep(1)
- print("No Response!")
- sleep(1)
- main()
- end
- elseif selector == (7) then
- print("Type in the id and password!")
- print("ID : ")
- term.setCursorPos(6,3)
- Hack = io.read()
- print("PassWord : ")
- term.setCursorPos(12,4)
- Hack2 = io.read()
- print("Connecting...")
- if tonumber(Hack) == nil then
- sleep(1)
- print("Invalid ID")
- sleep(1)
- main()
- end
- rednet.send(tonumber(Hack),"Connect",tonumber(Hack2))
- id,msg = rednet.receive(5)
- if msg == ("success") then
- textutils.slowPrint("Access Granted!")
- term.clear()
- term.setCursorPos(1,1)
- logged()
- sleep(1)
- elseif msg == ("fail") then
- print("ID or PassWord was incorrect!")
- sleep(1)
- main()
- elseif not id then
- print("No Response!")
- sleep(1)
- main()
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement