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

Lumberjack turtle: Not dropping wood in correct chest

Started by AquatikJustice, 15 June 2013 - 01:38 PM
AquatikJustice #1
Posted 15 June 2013 - 03:38 PM
First off, the current code: http://pastebin.com/pLH2jAzk

Now, the issue:
The turtle runs fine, waiting for a sapling to grow into a tree before cutting it down. The issue comes when it goes to put the wood in/take saplings out of their respective chests. It keeps dropping the wood into the sapling chest. This is an issue since the wood from the wood chest is being pumped into a furnace to be turned into charcoal. I've been looking at this code for the past hour and apparently my brain isn't letting me see the issue.
Lyqyd #2
Posted 15 June 2013 - 08:34 PM
Split into new topic.
Bomb Bloke #3
Posted 15 June 2013 - 08:53 PM
Lines such as:

if saplingChest == "right" or "Right" then

… aren't valid. It checks to see whether saplingChest == "right" is true, or if "Right" exists; since the term "Right" always exists (because you wrote it there!) the final result is always true.

Instead use:

if saplingChest == "right" or saplingChest == "Right" then

… or better yet:

if string.lower(saplingChest) == "right" then

Or better yet, convert the user input to lower-case as soon as it's entered, and store it that way so you don't need to worry about it anywhere else in the program.
AquatikJustice #4
Posted 15 June 2013 - 09:32 PM
Works perfectly now. Many thanks Bomb!