Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local i, width, height, percentage, phase, phaseColor, senderId, distance, protocol, fuelLevel, fuelFound, tries, timeout, marquee, ypos;
- local arg={...};
- local function help()
- print("To use this program put a wireless modem on the left side of the computer and a 3x2 (3 width, 2 height) display to the right.");
- end
- local function setBoot()
- file=fs.open("startup", "w");
- file.write("shell.run(\"BMReceiver\", \"start\");");
- file.close();
- end
- local function resetMonitor()
- t.setTextScale(1);
- t.setBackgroundColor(colors.black);
- t.setCursorPos(1, 1);
- t.setTextColor(colors.white);
- width, height=t.getSize();
- end
- local function getElement(data, pos) --Parse a string (with format *,*,*,[...]) and return the elemnt "pos"
- local count, i, returnValue;
- count=0;
- while(count<=pos)
- do
- i=1;
- while(string.char(string.byte(data, i))~="," and i<=#data)
- do
- i=i+1;
- end
- returnValue=string.sub(data, 0, i-1);
- data=string.sub(data, i+1);
- count=count+1;
- end
- return returnValue
- end
- if (#arg==0)
- then
- printError("You have to specify an argument.");
- print("\nArguments:");
- print("help: Display an help guide.");
- print("id: Get the id of this computer to use with rednet.");
- print("start: Start the program.");
- print("setboot: This will cause the program to start automatically when the computer turns on.");
- return;
- elseif (#arg>1)
- then
- printError("Wrong number of argument");
- return;
- else
- if (arg[1]=="id")
- then
- print("Receiver id: "..os.getComputerID());
- return;
- elseif (arg[1]=="help")
- then
- help();
- return;
- elseif (arg[1]=="setboot")
- then
- setBoot();
- return;
- elseif (arg[1]~="start")
- then
- printError("Wrong argument");
- return;
- end
- end
- rednet.open("left");
- t=peripheral.wrap("right");
- phaseColor=colors.white;
- term.clear();
- term.setCursorPos(1, 1);
- t.clear();
- resetMonitor();
- tries=5;
- marquee=0;
- ypos=0;
- while(true)
- do
- if (tries>=5)
- then
- timeout=0.1;
- else
- timeout=20;
- end
- senderId, msg, distance, protocol=rednet.receive(timeout);
- t.clear();
- if (msg~=nil)
- then
- percentage=tostring(math.floor(tonumber(getElement(msg, 0))));
- phase=getElement(msg, 1);
- phaseColor=tonumber(getElement(msg, 2));
- fuelLevel=getElement(msg, 3);
- fuelFound=getElement(msg, 4);
- tries=0;
- term.clear();
- term.setCursorPos(1, 1);
- else
- if (tries<5)
- then
- tries=tries+1;
- print("Timeout... try number "..tries.." out of 5");
- end
- end
- if (tries<5)
- then
- --t.setTextScale(2);
- t.setTextColor(colors.lime);
- t.setCursorPos(width/2-string.len("Branch Mining")/2+1, 1);
- t.write("Branch Mining");
- resetMonitor();
- t.setCursorPos(1, 3);
- t.write("Phase: ");
- t.setTextColor(phaseColor);
- t.setCursorPos(string.len("Phase: ")+1, 3);
- t.write(phase);
- resetMonitor();
- t.setCursorPos(1, 4);
- t.write("Fuel level: "..fuelLevel);
- t.setCursorPos(1, 5);
- t.write("Fuel found: "..fuelFound);
- t.setCursorPos(width/2-string.len("Progress")/2+2, 7);
- t.write("Progress");
- for i=1,width-8
- do
- if (i<=(percentage/(100/(width-8))))
- then
- t.setBackgroundColor(colors.lime);
- else
- t.setBackgroundColor(colors.red);
- end
- t.setCursorPos((width/2-(width-8)/2)+i, 9);
- t.write(" ");
- end
- t.setBackgroundColor(colors.black);
- t.setCursorPos((width/2)-(string.len(percentage.."%")/2)+2, 8);
- t.write(percentage.."%");
- t.setTextColor(colors.gray);
- t.setCursorPos(width-string.len("by SolidSnake96AS")+1, height);
- t.write("by SolidSnake96AS");
- resetMonitor();
- else
- marquee=marquee+1.5;
- if (marquee>25)
- then
- marquee=-25;
- ypos=math.random(0,4);
- end
- resetMonitor();
- t.setTextColor(colors.gray);
- t.setCursorPos(width-string.len("by SolidSnake96AS")+1, height);
- t.write("by SolidSnake96AS");
- t.setTextColor(colors.lime);
- t.setCursorPos(width/2-string.len("Branch Mining Script")/2+1, 2);
- t.write("Branch Mining Script");
- t.setTextColor(colors.yellow);
- t.setCursorPos(width/2-string.len("StandBy")/2+1, 3);
- t.write("StandBy");
- resetMonitor();
- t.setTextColor(colors.red);
- t.setCursorPos(width/2-string.len(" __ _ _ ___ _ _ ")/2+1+marquee, 4+ypos);
- t.write(" __ _ _ ___ _ _ ");
- t.setTextColor(colors.orange);
- t.setCursorPos(width/2-string.len("/ _|| \\| || o ) \\_/ |")/2+1+marquee, 5+ypos);
- t.write("/ _|| \\| || o ) \\_/ |");
- t.setTextColor(colors.lime);
- t.setCursorPos(width/2-string.len("\\_ \\| \\\\ || o \\ \\_/ |")/2+1+marquee, 6+ypos);
- t.write("\\_ \\| \\\\ || o \\ \\_/ |");
- t.setTextColor(colors.cyan);
- t.setCursorPos(width/2-string.len("|__/|_|\\_||___/_| |_|")/2+1+marquee, 7+ypos);
- t.write("|__/|_|\\_||___/_| |_|");
- --[[
- __ _ _ ___ _ _
- / _|| \| || o ) \_/ |
- \_ \| \\ || o \ \_/ |
- |__/|_|\_||___/_| |_|
- ]]--
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement