Jump to content




Self-Replicating Turtle - Revisited


104 replies to this topic

#21 Inksaver

  • Members
  • 61 posts

Posted 14 May 2014 - 06:57 AM

@TurtleHunter
Thanks for posting the problem area. I have only looked at the image so far, and it is the presence of flint that is worrying me. the dig.digNew{} method should have identified and disposed of flint, and you never see it in the inventory, so I need to refine it. Also sticks and signs are still in the inventory because storageSigns and storageSticks chests have not yet been created and placed. I will perhaps change the code so that signs cannot be crafted until a storage chest has been placed.

@originalbit
Thanks also to the for the ideas concerning the file system. These will definitely be implemented. I am a bit OCD with code, and I like to anticipate any and all possibilities.

@darkrising
You are of course correct. lua means moon, and as it has been adopted as a proper noun to name the OS, then Lua with capitalisation on the first letter is the correct way of writing it. You will not see it again in all caps from me, and when I next edit my posts, it will be corrected.Nice to see others are also OCD...

First part of the tutorial has been written, should be uploading to the tutorials forum later today.

#22 Inksaver

  • Members
  • 61 posts

Posted 15 May 2014 - 11:36 AM

The problem highlighted by TurtleHunter shows how useful a logfile can be. The logfile he uploaded http://pastebin.com/wyY8Lkmy which is logHarvestRight1.txt has the following clues as to why a flint was still present in the turtle inventory

Line 614: dig.checkForItem: checkForItems = 'ironore','gravel','coal'
Line 615:		  slot.update: Slot 8 contains 1 item2 status = unknown

Not sure what item1 is at this stage as it has been there for a while, but item2 is almost certainly gravel or flint

Line 620: dig.checkForItem: checkForItems = 'ironore','gravel','coal'
Line 621:		slot.update: Slot 9 contains 1 item3 status = unknown

item2 and item3 are almost certainly gravel and flint

dig.checkForItem: checkForItems = 'ironore','gravel','coal'

At this stage another gravel dug into slot 8, allowing a test to be made, as need 2 blocks to test:
checkSandGravel: gravel or sand dropped, moving down
checkSandGravel: checking for gravel/sand - found gravel in slot 8
checkSandGravel: checking for gravel/sand - found gravel in slot 8
dig.newDig: sorting inventory after identifying new item
sortInventory: Sorting started, moveItems = true
sortInventory: resetting unknown items
sortInventory: debug log
		sortInventory: slot 1 slotCount = 9 of wood			 slotState = known
		sortInventory: slot 2 slotCount = 1 of chests		   slotState = known
		sortInventory: slot 3 slotCount = 52 of dirt			slotState = known
		sortInventory: slot 4 slotCount = 2 of saplings		 slotState = known
		sortInventory: slot 5 slotCount = 61 of cobble		  slotState = known
		sortInventory: slot 6 slotCount = 3 of sand			 slotState = known
		sortInventory: slot 7 slotCount = 2 of gravel		   slotState = known
		sortInventory: slot 8 slotCount = 1 of item1			slotState = unknown
		sortInventory: slot 9 slotCount = 3 of item2			slotState = unknown

The gravel in slot 8 (item2) has been identified and sortInventory() has re-allocated the itemX names to the remaining unidentified items, after moving gravel into slot 7, so all identified items are grouped together.

I guess item1 is now definitely flint. The reason it was not identified is the function checkSandGravel() only tries to identify the item in the slot passed to it. As sand was already known, there was no need to confirm gravel by breaking it until flint is produced. This was obviously a mistake, so the function has been re-written to confirm gravel by breaking it until it turns to flint, then the new flint, and any already present can be dumped in one go.
The function has now been moved into the dig() object and renamed clsDig.checkSandGravel()

I will be uploading the changes to pastebin very shortly, with a version number on the first line of 1.0.1
Part 2 of the tutorial is nearly ready

#23 TurtleHunter

  • Members
  • 112 posts

Posted 15 May 2014 - 08:48 PM

Suggestions: 1- Use the new computercraft features to use rednet on the turtle(swapping the crafting table with a rednet modem) to another computer
2- If it find enoght gold, craft advanced turtles

#24 Pizza Fox

  • Members
  • 6 posts
  • Locationwhere am i

Posted 18 May 2014 - 02:55 PM

I keep having a bug when it places a furnace

harvestAllTrees: changing logFile Name
from logStart.txt to logHarvestRight1.txt END OF LOGFILE!
restoreTorches: started. side =
rightside colNo = 0
start.lua:10317: attempt to compare number with string expected, got number

I am using MC 1.6.4 CC 1.6.3

#25 Inksaver

  • Members
  • 61 posts

Posted 19 May 2014 - 03:28 PM

I will upgrade to CC 1.6.3 later today and give it a test run.
Could you please post the seed of the world you are using, the coordinates of the tree, and the direction you are facing when placing the turtle.

#26 Pizza Fox

  • Members
  • 6 posts
  • Locationwhere am i

Posted 20 May 2014 - 09:39 PM

View PostInksaver, on 19 May 2014 - 03:28 PM, said:

I will upgrade to CC 1.6.3 later today and give it a test run.
Could you please post the seed of the world you are using, the coordinates of the tree, and the direction you are facing when placing the turtle.

My coordinates from standing behind the turtle facing the tree, with the chest thing facing me (East) are, X 161 Y 67 Z 282 I am using the seed oakforest like in the instructions.

Edited by minecrafter1094, 22 May 2014 - 12:20 AM.


#27 mistamadd001

  • Members
  • 76 posts

Posted 21 May 2014 - 10:32 AM

I keep getting a slot 0 out of range error, it has happened every time the program is run, I am replacing the turtle and replacing the tree every time.

Please give me an idea as to why this is happening

the seed is: -2785521036684775193

and my coords are: -227x, 64y, 239 facing south

the error occurs straight after returning to ground level after completely mining the firstTree, I'm assuming the turtle tries to place the chest it crafted and then dump stuff into it, however the chest does not get placed and the turtle just spits its items out

I also had one on saplingCheck just now during the firstTree object

Hoping this helps

#28 Inksaver

  • Members
  • 61 posts

Posted 22 May 2014 - 07:43 AM

@ minecrafter1094
The version has changed a couple of times since I first posted, and I did not keep backups of the earlier versions, so the error at line 10317 no longer gives the correct error point.
Could you download the latest version from Pastebin The first line of the script reads -- start.lua Version 1.0.2

Try it again and if it comes up with the same error, give the message as you did before, with the line number hopefully being more meaningful.
Also if you post the logfile either as an attachment here, or on pastebin, that would be very helpful.

When I used the location you posted, the tree is not big enough, and the turtle ran out of fuel at the end of its first run, so try a different position. I have edited my original post to emphasise the tree height is important.

@mistamad001
Could you check the seed you posted is exactly the same, as the one above is nowhere near any trees, so I am guessing there might be a number missing, or in the wrong place

Edited by Inksaver, 22 May 2014 - 07:44 AM.


#29 Dragon53535

  • Members
  • 971 posts
  • LocationIn the Matrix

Posted 22 May 2014 - 08:58 AM

Your turtle fails to craft items sometimes and screws up. one error was on line 7167, there were no planks to refuel so it tried searching item slot 0 and failed since there is no slot 0.

#30 Inksaver

  • Members
  • 61 posts

Posted 22 May 2014 - 10:03 AM

The line causing the error is
turtle.select(slot.getItemSlot(slot, "planks"))
This means there is no slot containing planks, which in turn means they were not crafted on the previous line
craft{craftItem = "planks", craftQuantity = numLogs * 4, sourceItem1 = "wood", destSlot = 0, doSort = false}
The only reason I can think why this might happen is if the tree was less than 6 blocks high.
Try altering the last few lines of code in firstTree() to
numLogs = turtle.getItemCount(slot:getItemSlot("wood")) - 1
if numLogs < 3 then
  saveToLog("firstTree: Only "..numLogs.." logs available. Not enough to continue. Re-start at a taller tree", true)
  error()
end
if numLogs > 4 then
  numLogs = 4
end
if craft{craftItem = "planks", craftQuantity = numLogs * 4, sourceItem1 = "wood", destSlot = 0, doSort = false} then
  turtle:select(slot.getItemSlot("planks"))
  turtle.refuel()
  slot.update{self = slot, item = "planks", delete = true}
else
  saveToLog("firstTree: Failed to craft planks. Check if more than 1 wood available", true)
  error()
end
It may be easier to re-download from Pastebin (Version 1.0.3)
Could you try that and report back, or even better reply with the seed of your world, and the coordinates of the tree you are placing your turtle

Edited by Inksaver, 22 May 2014 - 10:11 AM.


#31 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 22 May 2014 - 10:24 AM

Can i make a suggestion... make use of

[spoiler]
[/spoiler]


and/or

[namedspoiler=name]
[/namedspoiler]


in the OP so that its not as long ;) just nicer to have things grouped, etc.

#32 Inksaver

  • Members
  • 61 posts

Posted 22 May 2014 - 10:49 AM

if suggestion == "good idea" or suggestion == "makes sense" then
	os.run("execute suggestion")
end


#33 Dragon53535

  • Members
  • 971 posts
  • LocationIn the Matrix

Posted 22 May 2014 - 07:43 PM

Turtle just crashed after first tree with the updated script
start.lua:6501: attempt to index ? (a nil value)
the line is if self.slotContains[i] == item then
It just finished sorting inventory when it stopped.

#34 Inksaver

  • Members
  • 61 posts

Posted 22 May 2014 - 08:27 PM

Ah very sorry, that's what happens if you do things in a rush.

Change
turtle.select(slot.getItemSlot("planks"))

to
turtle.select(slot:getItemSlot("planks"))
on line 7170
Note colon instead of dot

Edited by Inksaver, 22 May 2014 - 08:38 PM.


#35 Dragon53535

  • Members
  • 971 posts
  • LocationIn the Matrix

Posted 22 May 2014 - 08:51 PM

View PostInksaver, on 22 May 2014 - 08:27 PM, said:

Ah very sorry, that's what happens if you do things in a rush.

Change
turtle.select(slot.getItemSlot("planks"))

to
turtle.select(slot:getItemSlot("planks"))
on line 7170
Note colon instead of dot

Did, quit at the same spot, it expected a number there...

#36 Inksaver

  • Members
  • 61 posts

Posted 22 May 2014 - 10:55 PM

Check you have not got turtle:select (with a colon instead of a dot.)

I got it running on cc 1.6.3 but with a strange error when it came to placing the torch in front of the chest placed to act as a storage chest for torches. At this point I mis-spelt the variable used to hold text in the line
local markerlogText = "placeStorage: placing marker "..storageName
(line 6199)
Then when called to write to the logfile, because I put:
saveToLog(markerLogText, true, false)
(Note the capital L)
this called:
function saveToLog(text, toScreen, verbose)
  toScreen = toScreen or true
  verbose = verbose or false

  if toScreen then
	print(text)
  end
  if fso:getUseLog() then
	fso:appendLine(text, verbose)
  end
end
On cc 1.5.2 this had no effect that I was trying to write Nil to a text file, but on 1.6.3 the code simply stopped, with no error report.
To prevent this happening again, I modified the code to:
function saveToLog(text, toScreen, verbose)
  toScreen = toScreen or true
  verbose = verbose or false
  text = text or "Nil instead of text supplied, check your code!"

  if toScreen then
	print(text)
  end
  if fso:getUseLog() then
	fso:appendLine(text, verbose)
  end
end

Re-uploaded to pastebin as version 1.0.5

#37 Dragon53535

  • Members
  • 971 posts
  • LocationIn the Matrix

Posted 23 May 2014 - 02:33 AM

I've been testing your turtle, it worked to the gather cobble, but when it went to find more wood, it found the sugarcane and broke.

It did not give an error however it dug 2 sand underneath the sugarcane and started just spitting out this forever

dig.newDig: did not succeed after detect(), bedrock reached dig = 0 of bedrock into slot 0 at x=273 y=60 z=257

It's odd as it only hit smooth stone...
The turtle did however find the top of the sugarcane and dig down onto it, but then just dug the 2 sand underneath and broke
i had to terminate the program afterwards...

The same problem sort of happened again, however this time it didn't encounter the sugarcane and instead started or tried to start it's mine right next to water and when it went down a couple of blocks it said something about a cobble stopper, but didn't do anything, so i blocked off the water and he worked again, he even mined in the water a bit afterwards which confused me.

the water is the problem, after it dug up the second side on the mine, it encountered water above it while trying to go up, and calls it bedrock... removing the water works. Also i think my turtle got in a loop on checking if the sand is gravel. Eventually it stops and sorts, and then goes at it again. The line it tells me about is line 356 when i terminated which, guess what, you didn't have anything there about if it WAS sand.

Edited by Dragon53535, 23 May 2014 - 03:48 AM.


#38 Inksaver

  • Members
  • 61 posts

Posted 23 May 2014 - 06:23 AM

Thanks for reporting the errors you are getting. We seem to be making progress!
It would be very helpful if you could post the seed of your world and the coordinates and direction facing at the first tree
(press T while playing then type /seed Enter)

Edit: sand and gravel check now working. Just need to look at the water problem, will upload ASAP
Also discovered a redstone from storage problem at the turtle crafting stage.

Edited by Inksaver, 23 May 2014 - 11:36 AM.


#39 Dragon53535

  • Members
  • 971 posts
  • LocationIn the Matrix

Posted 23 May 2014 - 04:27 PM

Coords of first tree (i've remade the tree a few times so i don't know if it was high enough, made sure it was every time afterwards.)
x:264 y:65 z:254 Seed is -991485530 i faced west on the tree and started the turtle facing that way.

There was no sugarcane nearby so i put the sugarcane on x:273 z:257

Edited by Dragon53535, 23 May 2014 - 04:28 PM.


#40 mistamadd001

  • Members
  • 76 posts

Posted 24 May 2014 - 02:37 AM

Hi InkSaver, I've just tried the latest program 1.0.5 but am having the same error, I am running 1.4.7 so I fear that that is the reason my program is failing so early. I'm still getting a turtle:18: Slot number 0 out of range.

There are several things that I am noticing are a bit odd, every time the turtle collects a sapling (spruce) it is spitting it out and not checking to see if it in fact a sapling, saying instead that it is an apple.

Im not sure if this is because of 1.4.7 or what but it is strange.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users