This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
PrayerHater's profile picture

Refueling function question

Started by PrayerHater, 22 January 2016 - 05:20 AM
PrayerHater #1
Posted 22 January 2016 - 06:20 AM
I just finished writing a program (I'll edit it in later if you think I should/need to or are interested in checking it out) for planting five different crops in a certain pattern in a 9x9 farm and got the pattern and whatnot down perfect, then I put a simple getFuelLevel, if less than x, select(x), refuel(x) function into places it should be, and then I started the program. That's when it hit me. I thought "Oh crap. If/when it refuels after planting a row, it's not going to plant anymore of whatever it was just planting because the turtle will have the fuel selected until it gets to whatever it's supposed to plant next."

So, I need to know if there's a simple way of making a turtle detect what slot is selected before it selects the slot with the fuel in it and then select the slot that was previously selected and continue planting the correct crop or if I need to rewrite my program (which would of course make it longer and a pain in the butt.

I admit, I am an amateur and am not great at this mod yet, but I also don't feel like combing through tutorials right now because as I'm writing this I'm very tired. Haha. So please, any help you can offer would be much appreciated.
Bomb Bloke #2
Posted 22 January 2016 - 06:58 AM
Assuming you're on ComputerCraft 1.6 or later, there's turtle.getSelectedSlot(). Record the slot, do your fuelling thing, then just set it back to where it was.
PrayerHater #3
Posted 22 January 2016 - 07:42 AM
Assuming you're on ComputerCraft 1.6 or later, there's turtle.getSelectedSlot(). Record the slot, do your fuelling thing, then just set it back to where it was.

How do you record it?
Bomb Bloke #4
Posted 22 January 2016 - 07:59 AM
variableToRecordTo = turtle.getSelectedSlot()
PrayerHater #5
Posted 22 January 2016 - 08:15 AM
variableToRecordTo = turtle.getSelectedSlot()

Thank you so much. Tested and it works perfectly. :D/>