Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear();
- term.setCursorPos(1,1)
- print("Turtle Mining Client")
- print("Starting...");
- print("Setting Up Modem");
- local run = false;
- local hasModem = false;
- local modemSide;
- local modemProtocol = "mining"
- local modemHostname;
- if peripheral.getType("right") == "modem" then hasModem = true; modemSide = "right";
- elseif peripheral.getType("left") == "modem" then hasModem= true; modemSide = "left";
- elseif peripheral.getType("front") == "modem" then hasModem= true; modemSide = "front";
- elseif peripheral.getType("back") == "modem" then hasModem= true; modemSide = "back";
- elseif peripheral.getType("top") == "modem" then hasModem= true; modemSide = "top";
- elseif peripheral.getType("bottom") == "modem" then hasModem= true; modemSide = "bottom";
- else term.setTextColor(colors.red); print("Error: No Modem Found! Please ensure that a modem is connected to the turtle."); term.setTextColor(colors.white); os.exit()
- end
- rednet.open(modemSide);
- for i=1, 25, 1 do
- rednet.unhost(modemProtocol, "MiningTurtle" .. i) --Ensures that turtle does not already have this hostname.
- local checkForTurtle = rednet.lookup(modemProtocol, "MiningTurtle" .. i);
- if checkForTurtle == nil then modemHostname = "MiningTurtle" .. i; rednet.host(modemProtocol, "MiningTurtle" .. i); run = true; break; end
- end
- if run == false then
- term.setTextColor(colors.red);
- print("There Seems to be no slot available...Exiting");
- term.setTextColor(colors.white);
- os.exit();
- else
- term.setTextColor(colors.green);
- print("Set hostname to " .. modemHostname);
- term.setTextColor(colors.white);
- end
- while true do
- sleep(0)
- local event, key = os.pullEvent("key") -- limit os.pullEvent to the 'key' event
- if key == keys.space then break; end
- end
- --Ending Program
- print("Exiting Program...Please do not turn off system.\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement