Jump to content




Pet Turtles! because who doesn't want a pet robot?

turtle

  • This topic is locked This topic is locked
10 replies to this topic

#1 goreae

  • New Members
  • 4 posts

Posted 06 November 2012 - 03:52 PM

I'm not the best programmer in the world, and I just started messing with CC a few days ago, but I'm pretty proud of this.

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


#2 Shnupbups

  • Members
  • 596 posts
  • LocationThat place over there. Y'know. The one where I am.

Posted 10 November 2012 - 08:29 PM

There is an error on line 52. You forgot to put spaces between turtle.getFuelLevel() and < and 100.

#3 rhyleymaster

  • Members
  • 186 posts
  • LocationCanada

Posted 10 November 2012 - 08:33 PM

Why not create something like the Tomigotchi things with this? That would be awesome to see that as a Pet turtle.

#4 WeeHeeHee

  • New Members
  • 3 posts

Posted 20 November 2012 - 08:14 PM

I love this code! But do you know what makes it better? Adding turtle.attack(); sleep(1) randomly and putting it in the machinery room :(/>

#5 notyepenyar

  • Members
  • 5 posts

Posted 16 December 2012 - 05:43 PM

looked away for less than a minute...

#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 18 December 2012 - 12:24 AM

View PostShnupbups100, on 10 November 2012 - 08:29 PM, said:

There is an error on line 52. You forgot to put spaces between turtle.getFuelLevel() and < and 100.

white space doesn't matter.

#7 RunasSudo-AWOLindefinitely

  • Signature Abuser
  • 249 posts
  • Location/dev/earth1aus5

Posted 27 December 2012 - 06:47 PM

View PostShnupbups100, on 10 November 2012 - 08:29 PM, said:

There is an error on line 52. You forgot to put spaces between turtle.getFuelLevel() and < and 100.
There was an error in the entire thing. You have to replace newlines with spaces to conserve space and look more professional.
while true do if not abc then abc=true end f1return=function1(abc) abc=f1return if abc==17 or (abc==16 and dothing()) then abc=12 end return function1(nil) end


#8 Dusty_Rebel

  • Members
  • 57 posts

Posted 05 January 2013 - 05:39 PM

Looks Pretty Neat....

#9 Moti

  • Members
  • 9 posts

Posted 18 September 2013 - 03:58 PM

Cool code, I'm waiting for updates.

#10 kreezxil

  • Members
  • 128 posts
  • LocationBowie, TX

Posted 18 September 2013 - 04:59 PM

yeah it needs turtle attack in it. I think if it detects that is getting low on fuel it should enter panic mode and start digging looking for coal. Therefore 1 coal should always remain unused and it could use this loop to refuel itself:
turtle.select(1)
quantity=turtle.getItemCount(1)
if quantity > 1 then
  turtle.refuel(quantity-1) -- leave just one there, hopefully it is coal, that one is used for comparison when digging
end
for i=2,16 do
  turtle.select(i)
  turtle.refuel() -- atttempt to refuel off of entire stack
end


#11 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 18 September 2013 - 05:50 PM

Leave dead topic dead if there's nothing useful to add to them.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users