Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back");
- local connected = 0;
- local serverName = nil;
- local serverID = 0;
- function repaint()
- term.setCursorPos(1, 1);
- term.setBackgroundColor(colors.white);
- for i = 1, 20 do
- for j = 1, 26 do
- write(" ");
- end
- print();
- end
- if (connected == 0) then
- term.setBackgroundColor(colors.red);
- else
- term.setBackgroundColor(colors.green);
- end
- term.setTextColor(colors.white);
- term.setCursorPos(1, 1);
- write(" ");
- term.setCursorPos(1, 20);
- write(" ");
- term.setCursorPos(1, 1);
- write(serverName);
- end
- function settings()
- end
- function connectToServer()
- rednet.broadcast("$INFO");
- id, msg = rednet.receive(5);
- if (msg == nil) then
- showErrorMessage("No Carrier");
- sleep(3);
- os.reboot();
- else
- serverName = "Searching for Carrier..."
- store = msg;
- serverID = id;
- connected = 1;
- end
- end
- function showErrorMessage(message)
- term.setBackgroundColor(16384);
- term.setTextColor(1);
- for i = 8, 13 do
- term.setCursorPos(2, i);
- for j = 1, 24 do
- write(" ");
- end
- print();
- end
- term.setCursorPos(11, 9);
- write("Error");
- term.setCursorPos(4, 11);
- write(message);
- end
- function showInformationMessage(title, line1, line2)
- term.setBackgroundColor(colors.lightBlue);
- term.setTextColor(colors.white);
- for i = 8, 13 do
- term.setCursorPos(2, i);
- for j = 1, 24 do
- write(" ");
- end
- print();
- end
- if title == nil then
- term.setCursorPos(3, 9);
- write(title)
- else
- term.setCursorPos(3, 9);
- write(title);
- end
- term.setCursorPos(4, 11);
- write(line1);
- term.setCursorPos(4, 12);
- write(line2);
- end
- function showOSInformation()
- term.setBackgroundColor(1);
- term.setTextColor(256);
- term.setCursorPos(4, 5);
- write("PDATerm v0.1");
- term.setCursorPos(4, 7);
- write("A Free Mobile Terminal");
- term.setCursorPos(4, 8);
- write("for ComputerCraft");
- end
- function lock()
- term.setCursorPos(1, 1);
- term.setBackgroundColor(32768);
- term.setTextColor(1);
- for i = 1, 20 do
- for j = 1, 26 do
- if (i == 1 or i == 20 or j == 1 or j == 26) then
- term.setBackgroundColor(16384);
- end
- write(" ");
- term.setBackgroundColor(32768);
- end
- if (i ~= 20) then
- print();
- end
- end
- term.setCursorPos(5, 3);
- write("--Enter Passcode--");
- cpass = "1234";
- pass = "";
- term.setTextColor(1);
- while(pass ~= cpass) do
- pass = "";
- term.setCursorPos(5, 15);
- write(" - - - - ");
- for i = 1, 4 do
- term.setCursorPos(5 + i * 3, 15);
- local event, key = os.pullEvent("char");
- pass = pass .. key;
- write("*");
- end
- end
- end
- function showInputDialog(message)
- term.setBackgroundColor(512);
- term.setTextColor(1);
- for l = 6, 17 do
- term.setCursorPos(2, l);
- for k = 1, 24 do
- write(" ");
- end
- print();
- end
- term.setCursorPos(4, 6);
- io.write(message)
- term.setCursorPos(5, 14);
- input = io.read()
- return input;
- end
- function rednetControl()
- term.setCursorPos(1, 1);
- term.setBackgroundColor(8);
- term.setTextColor(1);
- for i = 1, 20 do
- for j = 1, 26 do
- if (i == 1 or i == 20 or j == 1 or j == 26) then
- term.setBackgroundColor(2048);
- end
- write(" ");
- term.setBackgroundColor(8);
- end
- if (i ~= 20) then
- print();
- end
- end
- term.setCursorPos(3, 3);
- write("Advanced Rednet Console");
- term.setBackgroundColor(colors.orange);
- term.setCursorPos(3, 6);
- write(" OPEN Rednet ");
- term.setCursorPos(3, 8);
- write(" CLOSE Rednet ");
- term.setCursorPos(3, 10);
- write(" Rednet Broadcast ");
- term.setCursorPos(3, 12);
- write(" Send Message ");
- term.setCursorPos(3, 14);
- write(" Get Message ");
- term.setCursorPos(3, 16);
- write(" Computer ID ");
- term.setCursorPos(3, 18);
- write(" Exit ");
- local event, button, x, y = os.pullEvent("mouse_click");
- if (button == 1) then
- if (y == 6) then
- rednet.open("back");
- showInformationMessage("Rednet Turned On");
- sleep(2);
- end
- if (y == 8) then
- rednet.close("back");
- showInformationMessage("Rednet Turned Off");
- sleep(2);
- end
- if (y == 10) then
- message = showInputDialog("Broadcast Message");
- showInformationMessage("Broadcast Sending...","Broadcasting...", "");
- rednet.broadcast(message);
- sleep(2);
- end
- if (y == 12) then
- id = tonumber(showInputDialog("Target ID"));
- message = showInputDialog("Enter Message");
- showInformationMessage("Sending Message...", "");
- rednet.send(id, message);
- sleep(2);
- end
- if (y == 14) then
- timeout = tonumber(showInputDialog("Enter Timeout"));
- showInformationMessage("Rednet","Waiting for", "message");
- id, msg = rednet.receive(timeout);
- if (msg == nil) then
- showErrorMessage("Receive Timeout.");
- sleep(2);
- else
- showInformationMessage("Data Received!",id, msg);
- sleep(5);
- end
- end
- if (y == 16) then
- showInformationMessage("Message","Computer ID", os.getComputerID());
- sleep(5);
- end
- if (y == 18) then
- return;
- end
- rednetControl();
- end
- end
- function displayMainMenu()
- term.setTextColor(colors.red);
- term.setCursorPos(2, 5);
- term.setBackgroundColor(colors.yellow);
- write(" Current GPS Position ");
- term.setCursorPos(2, 7);
- term.setBackgroundColor(colors.lightGray);
- write(" Mail System ");
- term.setCursorPos(2, 9);
- term.setBackgroundColor(colors.lightGray);
- write(" Enter Chat ");
- term.setCursorPos(2, 11);
- term.setBackgroundColor(colors.yellow);
- write(" Rednet Console ");
- term.setCursorPos(2, 13);
- term.setBackgroundColor(colors.lightGray);
- write(" Settings ");
- term.setCursorPos(2, 15);
- term.setBackgroundColor(colors.yellow);
- write(" Reconnect ");
- term.setCursorPos(2, 17);
- term.setBackgroundColor(colors.yellow);
- write(" Shutdown ");
- local event, button, x, y = os.pullEvent("mouse_click");
- if (button == 1) then
- if (y == 5) then
- showInformationMessage("Please wait...","Getting Location", "");
- if (gps.locate(2) == nil) then
- showErrorMessage("No GPS Signal.");
- sleep(2);
- else
- x, y, z = gps.locate();
- showInformationMessage("GPS","Your Location: ", x .. ", " .. y .. ", " .. z);
- sleep(5);
- end
- end
- if (y == 7) then
- end
- if (y == 9) then
- end
- if (y == 11) then
- showInformationMessage("Loading...","Please Wait...", "");
- sleep(2);
- rednetControl();
- end
- if (y == 13) then
- end
- if (y == 15) then
- showInformationMessage("Loading...","Connecting...", "");
- connected = 0;
- connectToServer();
- end
- if (y == 17) then
- showInformationMessage("Goodbye","Shutting Down...", "");
- sleep(2);
- os.shutdown();
- end
- end
- repaint();
- displayMainMenu();
- end
- lock();
- connectToServer();
- repaint();
- showOSInformation();
- if (connected == 0) then
- showErrorMessage("No Carrier");
- sleep(5);
- os.reboot();
- else
- sleep(0.75)
- serverName = store
- repaint();
- showOSInformation();
- showInformationMessage("Carrier Located","Connected to", serverName);
- sleep(3);
- end
- repaint();
- displayMainMenu();
Advertisement
Add Comment
Please, Sign In to add comment