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

Some Turtle.compare questions

Started by willhoot, 10 June 2014 - 11:53 AM
willhoot #1
Posted 10 June 2014 - 01:53 PM
I have some questions about the turtle.compare function.
First off is there a way to have it compare to a item/block id number? I want to have it compare to a block without having to keep that block in the inventory (specifically so my farming turtle doesn't try to destroy my fences when it has to pass over them).
Second off is there a way for it to detect a fully grown plant? ether by block id or by having it compare to the crop? because I don't want it to harvest crops that aren't ready and I want a fully automated system (so I don't have to start the harvest by timing when the crops are ready). If there is a way does it work with magical crops?

If these aren't options they really should be.
Thanks
Will
KingofGamesYami #2
Posted 10 June 2014 - 01:56 PM
block ids - no
comparing to blocks in world - yes, but you need a fence in your inventory
grown plant - no
Bomb Bloke #3
Posted 10 June 2014 - 03:12 PM
For what it's worth, you could just have the turtle do the timing for you - make it gather up everything in the field every hour, for eg. Not everything will grow in that time, but the percent wasted will be minimal.

Given how long it takes for things to grow, constantly wandering around the field looking for ready plants would add up to a much higher fuel cost per plant anyways (as you'll pass over most plants multiple times before they're ready to actually dig up). Granted you'd get wheat a little bit faster if you minimised the time between each plant hitting maturity and being replanted, but unless you're wanting a constant supply of plantballs or something, I doubt you'll need maximum speed.

In regards to determining where it's safe to dig, consider setting up a GPS for use with the GPS API. If the turtle knows its location, then it can also be told where it may and may not swing its hoe - along with where it should restart from if the server reboots or something.
Edited on 10 June 2014 - 01:15 PM
theoriginalbit #4
Posted 10 June 2014 - 03:31 PM
I definitely agree with Bomb Bloke here, to conserve fuel it could be more efficient to just have the Turtle harvest the crops at a particular time. You could make use of os.setAlarm or os.startTimer

Note: you may want to be careful with os.startTimer, if the chunk unloads, or the server restarts often enough and the timer is set too long, the Turtle may never harvest the crops, as such perhaps saving a temporary file with some basic information so you can restart the timer accurately could be of some benefit :)/>
Edited on 10 June 2014 - 01:31 PM