Jump to content




Self-Replicating Turtle - Revisited


90 replies to this topic

#81 Inksaver

  • Members
  • 59 posts

Posted 19 August 2014 - 10:24 PM

Thanks for your comments.

I would love to see your code. Perhaps you could put it on pastebin?

I may contunue with this, but at the moment I am working on a mining script that uses a lot of the functions I wrote to enable a player in survival mode to place a turtle down anywhere, give it a chest, dirt, cobble, stone, gravel, a bucket and a full stack of wood, and it will craft all it needs and mine out a 33x33 area in multiple layers with ladders and stone staircases, with full resume after server restart. It uses recursive functions to mine ores as efficiently as possible, and constructs floors in all layers, with signs giving levels and compass bearings, so the player can explore the mine with ease.

#82 lare290

  • Members
  • 53 posts
  • LocationFinland

Posted 04 July 2015 - 05:37 PM

View PostInksaver, on 12 May 2014 - 08:52 PM, said:

After all I am still a beginner!
Yeah, sure.

#83 wood

  • Members
  • 6 posts
  • LocationQuebec

Posted 13 January 2016 - 10:24 PM

@Inksaver, awesome progam !
I just started progaming during winter holiday and don't have much background in programing.
I'm going to try and make some sort of AI for my turtle, I hope I can do it as fast as you, if I'm done by the end of the year, it's a success :)
I read that you were going to make a tutorial, I was wondering if you started it ?

#84 jaketheraven

  • Members
  • 3 posts

Posted 06 June 2016 - 08:37 PM

When I run this it says slot number 0 out of range. I really want to use this. Please help.

Hey I just had an idea! What if you used the peripherals api to automatically activate the offsprings?

Edited by Bomb Bloke, 07 June 2016 - 01:45 AM.


#85 Meit

  • Members
  • 22 posts
  • LocationPK

Posted 24 July 2016 - 10:11 AM

Increase all slots number by 1 in the code, ITS COMMON SENSE..
They are going out of the range and ID's cause the codes been changed (slot ids start: 1, 1-10 = 9 slots)
So increase all slots Id's/numbers by 1 and it will work (even if it is 0 + 1 it should be 1,)

#86 dropdead

  • Members
  • 7 posts

Posted 17 November 2016 - 06:41 PM

Hi there!
I visit this forum for years since there is always a neat little program for this or that.
This self replicating turtle program is really great and obviously the creator took quite some time to make it that way.
I have tried it countless times but if it does not bug out because something confuses the turtle, the program stops when diamonds are found and it is back on the surface. The problem is always the same: slot number 0 out of range.
I get the problem but my grasp of Lua is not good enough to dig through all the code and fix it. I DO understand that Lua is a bit peculiar since it starts counting with 1 and not with 0 like most other languages.
And if I understand then slot 0 is out of range because it simply does not exist.
I tried all the world seeds the creator gave because they should work but somehow I am out of luck. The most of the program I've seen one time is the turtle making a pickaxe and then spitting it out for whatever reason. I never got that far again.

Any idea how to fix this since I've read more than once about this problem or is this thread too old? I could even provide the logs and such but I don't want to put all this stuff here if nobody can help anyway.


Thanks in advance!

Edit: Fixed some stuff. Stupid typos.

Edited by dropdead, 18 November 2016 - 05:32 AM.


#87 Lupus590

  • Members
  • 1,739 posts
  • LocationUK

Posted 18 November 2016 - 12:32 PM

View Postdropdead, on 17 November 2016 - 06:41 PM, said:

-snip-
does the error give a line number?

#88 dropdead

  • Members
  • 7 posts

Posted 18 November 2016 - 01:50 PM

View PostLupus590, on 18 November 2016 - 12:32 PM, said:

View Postdropdead, on 17 November 2016 - 06:41 PM, said:

-snip-
does the error give a line number?

It does, though I'd have to lie if I said anything more than it was about 3000 and had this time something to do with wood... (@_o) but I have started the program once again and it is already over two hours and the turtle has lots of resources gathered (deep mining soon). The error doesn't appear in the log and since your guess is as good as mine which line number the error threw yesterday time, I will tell you when
the program stops because if it finishes THIS TIME it would be a first.

View PostLupus590, on 18 November 2016 - 12:32 PM, said:

View Postdropdead, on 17 November 2016 - 06:41 PM, said:

-snip-
does the error give a line number?

Hi again.

Since I am still a brand new member, the first posts have to be approved but I have an error now. It occurs in line 2719 (function craft):

function craft(arg)
		-- code...
if arg.doSort == nil then
  arg.doSort = false
end
if arg.doSort then
  sortInventory(true)
end

if arg.sourceItem1 == nil then
  sourceSlot1 = 0
  sourceQuantity1 = 0
else
  sourceSlot1 = slot:getItemSlot(arg.sourceItem1)
  sourceQuantity1 = turtle.getItemCount(sourceSlot1) -- THIS IS LINE 2719!
end
	  
		-- code ...
end

This time the turtle didn't even find diamonds. Ten places in the turtles inventory contain items:

1x chest, 61x dirt, 61x cobblestone, 31x ironore,
1x stone, 24x coal, 61x gravel, 1x bucket,
1x redstonedust, 1x torch

Hope this helps.

Addendum1: Line 2719 is the same like yesterday and I can't shake the feeling that it is ALWAYS that line when the dig goes wrong.

Addendum2: Well, tried once again and it is line 2718 that throws the same error. Is it possible that the turtle is too packed with stuff?
This time it carried 16 slots full of items, spit out the planks and the program spit out that damn error...

MC 1.64
CC 1.63
Forge 9.11.1.1345

Edited by dropdead, 19 November 2016 - 03:28 PM.


#89 Inksaver

  • Members
  • 59 posts

Posted 09 January 2017 - 01:52 AM

Hi all
I have not looked at these forums for some time, so apologies to anybody who has left comments which I have not answered.
I just spotted this thread was still active, as I was about to post another program called "Survival Toolkit" which has been developed for use in survival mode and allows you to make use of your first Crafty Mining Turtle to mine without needing any supervision, flatten and clear surface areas, and create tree farms.

This version of the self-replicating turtle was developed before the ability to identify blocks and items was added, which is why it is so complicated.

There is a logging system, which if enabled can give clues to the cause of the errors described above.

As a suggestion, if you add a line above 2718:
print("About to use line 2718. arg.SourceItem1 = "..tostring(arg.SourceItem1))
and it errors out because arg.SourceItem1 = nil, and consequently sourceSlot1 = 0, which gives the error.

There is an updated version of this using MC 1.7.10 here http://pastebin.com/2Krm3Yva

#90 Beeskee

  • Members
  • 27 posts

Posted 12 August 2017 - 03:16 PM

This is still one of the most amazing computercraft things I've ever seen. :)

#91 nagoL2015

  • Members
  • 4 posts

Posted 25 October 2017 - 08:12 PM

This is by far the best and well-done script I have ever seen before in my experience with lua . Great job, keep up the amazing work :D.

Edited by nagoL2015, 27 October 2017 - 10:09 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users