my inspiration for this useless program is, when I first tried CC in tekkit, I thought that turtles could be kept as pets. I was horribly disappointed now, a month later, I decided to make a program that would make turtles act similar to vanilla mobs. the pathfinding isn't the best, but the turtle usually stays on the ground (or on your chests) and can walk up and down stairs. it's meant to be the startup program, but it can be used as a standalone program. it has no way of retrieving fuel, but will refuel when it needs to with the coal you put into the first slot. this is an impractical program that serves no specific purpose except for pet robots. because why not?
Pastebin: pastebin.com/SHZvURiZ (computer command pastebin get SHZvURiZ [codename])
Source Code:
function forward(n)
for i=1,n do
if not turtle.detectDown() then
turtle.down()
end
if not turtle.forward() then
if not turtle.detectDown() then
turtle.down()
end
if not turtle.up() then
break
end
if not turtle.forward() then
turtle.down()
break
end
end
if not turtle.detectDown() then
turtle.down()
end
end
end
function right(n)
turtle.turnRight()
forward(n)
end
function left(n)
turtle.turnLeft()
forward(n)
end
function back(n)
turtle.turnRight()
turtle.turnRight()
forward(n)
end
local L=0
while L==0 do
dir=math.random(1,4)
n=math.random(1,4)
if dir==1 then
forward(n)
end
if dir==2 then
right(n)
end
if dir==3 then
back(n)
end
if dir==3 then
left(n)
end
if turtle.getFuelLevel()<100 then
turtle.refuel()
end
if not (math.random(1,4)==1) then
sleep(math.random(1,5))
end
end