Main Menu

Farming Program Errors

Started by Lawreel, Dec 23, 2022, 07:36 AM

Previous topic - Next topic

Lawreel

So, I saw that this part of the forum is for posting about programs that you made, and would like to state that for starters, This is on the 1.7.10 version of the mod, and also not the ported over one, but since the forum for that is closed i cannot make a new one on the old forum. I have created a Farming Program but am running into several Errors that i'm having trouble understanding. The first one that I have been unable to stop is "Expected then" on this part of it

function getMoreFuel()
   if turtle.getFuelLevel() =< 20 then
      if turtle.getItemCount(1) > 1 then
         refuel()
      else
         if x > 0 then
            if face == 2 then
               resetTurtle()
            end
            if face == 1 then
               turnRightInc()
               resetTurtle()
            end
            if face == 0 then
               turnRightInc()
               turnRightInc()
               resetTurtle()
            end
            if face == 3 then
               turnLeftInc()
               resetTurtle()
            end
         end
         if x == 0 then
            resetTurtle()
         end
      turnLeftInc()
      turtleInsert()
      end
   end
end

Can Anyone help me figure out why this is breaking?
Also if your wondering 'face' is a Variable I made for keeping track which way its facing.

Lupus590

Can you post the full code and the full error (including the line number)? Uploading it to Pastebin might help.

As far as I can tell that code is not causing that error. So your problem probably is somewhere else, or you fixed the bug while copying to the forums.


Also, please use code tags to make things easier to read. It's the little paper icon with the <> on it.

The error message "Expected then" suggests that there is a problem with the syntax of the if statement on the first line of the function "getMoreFuel()". Specifically, the "=" character should be changed to "==" to indicate a comparison operator rather than an assignment operator. To fix this, the first line should be changed to:

if turtle.getFuelLevel() <= 20 then