Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This is code for the mod ComputerCraft. It works in CC 1.74. This is the code for the computer
- local args = {...}
- local function printAt(x,y,s)
- term.setCursorPos(x,y)
- term.write(s)
- end
- local function connect(Trgt)
- rednet.open(args[2])
- rednet.send(Trgt,"Ping","Ask")
- print("If this screen appears, pleas start 'Remote' on the turtle.\n\nTo end this program, please press 'CMD' + 'T'")
- rednet.receive("Ans")
- print(">> Connected to turtle "..Trgt)
- print("Use arrows to move the turtle.\n")
- TrgtID = Trgt
- end
- local function send(sInput)
- rednet.send(TrgtID,sInput,"CMD")
- local nID,sOutput,prt = rednet.receive("Ans")
- end
- local function update()
- local idT,blT,prT = rednet.receive("BLS")
- local idM,blM,prM = rednet.receive("BLS")
- local idD,blD,prD = rednet.receive("BLS")
- local idF,fuel,prF = rednet.receive("FL")
- local idF,coal,prF = rednet.receive("FL")
- term.clear()
- term.setCursorPos(1,1)
- print("TurtleCommander 1.2")
- print("Connected to turtle "..TrgtID)
- print("\nView of turtle:")
- print(blT)
- print(blM)
- print(blD)
- print("\nArrow keys to move the turtle")
- print("Space and LShift to move the turtle up and down")
- print("Enter to stop the program")
- print("Fuel level: "..fuel)
- print("Press 'X' to dig")
- print("Press 'C' to dig down and 'V' to dig up")
- print("Press 'R' to refuel")
- print(coal.." fuel item/s left")
- end
- term.clear()
- term.setCursorPos(1,1)
- if #args == 2 then
- connect(tonumber(args[1]))
- send("inspect")
- update()
- while true do
- local k,v = os.pullEvent()
- if k =="key" then
- local key = v
- if key == 208 then
- send("back")
- elseif key == 200 then
- send("forward")
- elseif key == 203 then
- send("turnLeft")
- elseif key == 205 then
- send("turnRight")
- elseif key == 57 then
- send("up")
- elseif key == 42 then
- send("down")
- elseif key == 28 then
- send("end")
- print(">> Connection terminated")
- break
- elseif key == 45 then
- send("dig")
- elseif key == 46 then
- send("digD")
- elseif key == 47 then
- send("digU")
- elseif key == 19 then
- send("refuel")
- else
- print("Not implemented")
- send("Nope")
- end
- update()
- sleep(0.2)
- end
- end
- else
- print("Usage: TurtleCommander <ID> [Modem]")
- end
Advertisement
Add Comment
Please, Sign In to add comment