This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
bpat's profile picture

Remote Turtle Program Now With Dig Up and Dig Down and Place Up And Down With Full List of Controls

Started by bpat, 05 May 2013 - 04:04 PM
bpat #1
Posted 05 May 2013 - 06:04 PM
Hi This is one of the first programs I have posted on here it is a Remote control turtle program. it has the features such as choosing what id the turtle is. Also what side the modem is on and of course controlling it. It tells you the controls and you can see them again by pressing the decimal key. also a nifty feature for mini games a redstone activation key. If you find any bugs on it please tell me
first here is the computer it is named turtlespy and please name it that


term.setBackgroundColor(colors.cyan)
print("  ")
term.clear()
term.setCursorPos(1,1)
print("Please Enter Side Modem Is On")
input = read()
rednet.open(input)
term.setBackgroundColor(colors.lime)
print(" ")
term.clear()
term.setCursorPos(18, 10)
print("Rednet Is Open")
sleep(2)
term.setBackgroundColor(colors.cyan)
print(" ")
term.clear()
term.setCursorPos(1, 1)
print("Please Enter Turtle ID")
input = tonumber(read())
term.setBackgroundColor(colors.lime)
print(" ")
term.clear()
term.setCursorPos(20, 10)
print("ID Accepted")
sleep(2)
term.setBackgroundColor(colors.cyan)
print(" ")
term.clear()
term.setCursorPos(1, 1)
term.setTextColor(colors.white)
print("Controls:")
print("Arrowkey Up = Forward")
print("Arrowkey Down = Back")
print("Arrowkey Left = Left")
print("Arrowkey Right = Right")
print("Numpad 0 = Place")
print("Numpad 2 = Up")
print("Numpad 4 = Redstone Activation")
print("Enter = Refuel")
print("Numpad 1 = Dig")
print("Numpad 5 = Dig Up")
print("Numpad 6 = Dig Down")
print("Numpad 7 = Place Up")
print("Numpad 8 = Place Down")
print("R Shift = Restart")
print("+ = Quit")
print(". Decimal = Show Controls")
print("Reminder If You Haven't Put Coal In The Turtle It Won't Move So Please Do.")
while true do
event, e = os.pullEvent("key")
if e == 200 then
  rednet.send(input,"forward")
  print("Moving Forward")
elseif e == 208 then
  rednet.send(input,"back")
  print("Moving Backwards")
elseif e == 203 then
  rednet.send(input,"left")
  print("Turning Left")
elseif e == 205 then
  rednet.send(input,"right")
  print("Turning Right")
elseif e == 82 then
  rednet.send(input,"place")
  print("Placing")
elseif e == 79 then
  rednet.send(input,"dig")
  print("Digging")
elseif e == 80 then
  rednet.send(input,"up")
  print("Going Up")
elseif e == 81 then
  rednet.send(input,"down")
  print("Going Down")
elseif e == 75 then
  rednet.send(input,"redstone")
  print("Redstone Switching On")
  sleep(1.5)
  print("Redstone Switching Off")
elseif e == 28 then
  rednet.send(input,"refuel")
  print("Refueling")
elseif e == 54 then
  shell.run("turtlespy")
elseif e == 83 then
  term.clear()
  term.setCursorPos(1, 1)
  print("Controls:")
  print("Arrowkey Up = Forward")
  print("Arrowkey Down = Back")
  print("Arrowkey Left = Left")
  print("Arrowkey Right = Right")
  print("Numpad 0 = Place")
  print("Numpad 2 = Up")
  print("Numpad 4 = Redstone Activation")
  print("Enter = Refuel")
  print("Numpad 1 = Dig")
  print("Numpad 5 = Dig Up")
  print("Numpad 6 = Dig Down")
  print("Numpad 7 = Place Up")
  print("Numpad 8 = Place Down")
  print("R Shift = Restart")
  print("+ = Quit")
  print(". Decimal = Show Controls")
elseif e == 78 then
  break
elseif e == 76 then
  rednet.send(input,"digup")
  print("Digging Up")
elseif e == 77 then
  rednet.send(input,"digdown")
  print("Digging Down")
elseif e == 71 then
  rednet.send(input,"placeup")
  print("Placing Up")
elseif e == 72 then
  rednet.send(input,"placedown")
  print("Placing Down")
end
end





and then the turtle it is named startup this one you can rename anything you want unless you are taking credit :P/>

rednet.open("right")
while true do
id, msg = rednet.receive()
if msg == "forward" then
  turtle.forward()
elseif msg == "back" then
  turtle.back()
elseif msg == "left" then
  turtle.turnLeft()
elseif msg == "right" then
  turtle.turnRight()
elseif msg == "place" then
  turtle.place()
elseif msg == "dig" then
  turtle.dig()
elseif msg == "up" then
  turtle.up()
elseif msg == "down" then
  turtle.down()
elseif msg == "refuel" then
  turtle.refuel()
elseif msg == "redstone" then
  redstone.setOutput("front",true)
  sleep(1.5)
  redstone.setOutput("front",false)
elseif msg == "digup" then
  turtle.digUp()
elseif msg == "digdown" then
  turtle.digDown()
elseif msg == "placeup" then
  turtle.placeUp()
elseif msg == "placedown" then
  turtle.placeDown()
end
end

I you would help me find out how to put download links please help me with that I don't know how to set one up so you will just have to copy and paste it onto a empty program sorry also my pastebin doesn't load it is most likely my internet so I might not make it that link if I do thankyou And Please enjoy Oh and quick suggestion for best sight change the gui in options/video settings while in minecraft to small
also put coal in the turtle and press refuel to get started
I have tested Everything and it works
bpat #2
Posted 05 May 2013 - 06:09 PM
also please give any questions and tell me if you like it or not or tell me things that would make it better
and also would love to find out how to use download links
calmilamsy #3
Posted 01 June 2013 - 01:17 PM
tip:-

to save ALOT OF CODING do this (this is an example)
lets say you do this for the computer:-


local function help()
print"replace this with the controls!"
end
x=read()
if x == "x" then
help()
else
rednet.send(computeridhere,x)
end
THIS will help alot and remove alot of unessisary code

for the turtle :-


rednet.recieve()
if x == "forward" then
turtle.forward()
rednet.send(computeridhere,`'Moving forwards`')
end
alot more even in coding as well :D/>

(i am actually not sure this will make it more compact but here is my suggestion!)