RoxRC
Wireless control for your Turtle
A very simple code with a clean UI designed to control a remote mining turtle. Most remote turtle programs I looked at make an effort to only control one turtle at once. This code doesn't include such protections and thus allows you to control more than one turtle at once if desired.
You may modify this code in any way you desire and share it with whomever you wish.
This code was designed for a Pocket Computer, though will work on a normal Computer if the wireless modem is on the back.
https://www.dropbox....oxRC%20Code.txt
-- This section goes on the controller. (Handheld computer recommended) -- local function RoxMaster() local run = 1 while run == 1 do local sEvent, param = os.pullEvent("key") if sEvent == "key" then if param == 17 then rednet.broadcast("MoveForward") elseif param == 30 then rednet.broadcast("MoveLeft") elseif param == 31 then rednet.broadcast("MoveBack") elseif param == 32 then rednet.broadcast("MoveRight") elseif param == 18 then rednet.broadcast("MoveUp") elseif param == 16 then rednet.broadcast("MoveDown") elseif param == 33 then rednet.broadcast("DigForward") elseif param == 19 then rednet.broadcast("DigUp") elseif param == 46 then rednet.broadcast("DigDown") elseif param == 45 then rednet.broadcast("EndTurtle") textutils.slowPrint("Ended program on the") textutils.slowPrint("current Turtle and closed") textutils.slowPrint("it\'s Rednet connection.") print("--------------------------") elseif param == 44 then rednet.broadcast("EndBoth") run = 0 rednet.close("back") textutils.slowPrint("Ended program on both") textutils.slowPrint("machines.") sleep(0.75) textutils.slowPrint("Closed rednet connection.") end end end end rednet.open("back") term.clear() textutils.slowPrint("Rox Remote Control Console \(RoxRCC\) sending signal.") print("--------------------------") textutils.slowPrint("WASD to move.") textutils.slowPrint("E to rise.") textutils.slowPrint("Q to fall.") textutils.slowPrint("F to dig forward.") textutils.slowPrint("R to dig up.") textutils.slowPrint("C to dig down.") textutils.slowPrint("X to stop current Turtle.") textutils.slowPrint("Z to exit.") print("--------------------------") RoxMaster() -- This section goes on the turtle. -- local function check() if turtle.getFuelLevel() < 5 then turtle.select(16) turtle.refuel(1) turtle.select(1) end end local function RoxSlave() local run = 1 while run == 1 do local scrap, message = rednet.receive() if message == "MoveForward" then check() turtle.forward() elseif message == "MoveBack" then check() turtle.back() elseif message == "MoveLeft" then turtle.turnLeft() elseif message == "MoveRight" then turtle.turnRight() elseif message == "MoveUp" then check() turtle.up() elseif message == "MoveDown" then check() turtle.down() elseif message == "DigForward" then turtle.dig() elseif message == "DigUp" then turtle.digUp() elseif message == "DigDown" then turtle.digDown() elseif message == "EndTurtle" then run = 0 rednet.close("right") textutils.slowPrint("Console ended program.") elseif message == "EndBoth" then run = 0 rednet.close("right") textutils.slowPrint("Console ended program.") end end end rednet.open("right") term.clear() textutils.slowPrint("Rox Remote Control Turtle \(RoxRCT\)") print("---------------------------------------") textutils.slowPrint("Receiver ready. Awaiting command from") textutils.slowPrint("the console.") textutils.slowPrint("Fuel is used from slot 16.") print("---------------------------------------") RoxSlave()
Edit: Pastebin codes now available!
RoxRCT (For the turtle): ZGmtKEkT
RoxRCC (For the console): kDiVVeRd
Edited by Roxforbraynz, 09 April 2014 - 04:13 AM.