6 posts
Location
Portland, OR
Posted 24 November 2015 - 09:35 AM
I wrote out a lengthy and super messy code for an automatic strip mining program than allows the user to enter the tunnel length and the number of tunnels. The last part I want to add to it is an inventory dumping program. The way I have it set up now checks the last open slot [slot 13] in the turtle for an item, and if there is one, it breaks the block below it, places down a chest from slot 14, and then dumps it's inventory in it. The issue is that if the turtle breaks a block over it's head, it goes in slot 1, but if it breaks the block directly in front of it, it goes in slot 13, so the dumping function runs way too often laying down a chest every other block. What would be the easiest way to fix this?
Pastebin file:
http://pastebin.com/rGLywaJwThank you for any help you can give!
7083 posts
Location
Tasmania (AU)
Posted 24 November 2015 - 10:23 AM
Items either go into the slot selected, or the first possible slot after it. So if you keep slot 1 selected this shouldn't be a problem.
Your positionNextLeft()/positionNextRight() functions select slot 15, and then your checkInv() function switches to slot 13. Your checkFuel()/torchCount()/checkInv() functions
may switch back slot 1 - but only if certain conditions are true.
Another thing, a
"for" loop could be used to reduce this:
Spoiler
turtle.select(1)
turtle.dropDown()
turtle.select(2)
turtle.dropDown()
turtle.select(3)
turtle.dropDown()
turtle.select(4)
turtle.dropDown()
turtle.select(5)
turtle.dropDown()
turtle.select(6)
turtle.dropDown()
turtle.select(7)
turtle.dropDown()
turtle.select(8)
turtle.dropDown()
turtle.select(9)
turtle.dropDown()
turtle.select(10)
turtle.dropDown()
turtle.select(11)
turtle.dropDown()
turtle.select(12)
turtle.dropDown()
turtle.select(13)
turtle.dropDown()
… to this:
Spoiler
for i = 1, 13 do
turtle.select(i)
turtle.dropDown()
end
Edited on 24 November 2015 - 09:24 AM