Jump to content




Automatic Dumping of Turtle's Full Inventory

turtle lua help

1 reply to this topic

#1 Doobliheim

  • Members
  • 6 posts
  • LocationPortland, 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/rGLywaJw

Thank you for any help you can give!

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (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

... to this:

Spoiler

Edited by Bomb Bloke, 24 November 2015 - 10:24 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users