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

[Lua] [Error] bios:338: [String "branchmine"]:35: '=' expected

Started by taylor6123, 07 February 2013 - 07:05 PM
taylor6123 #1
Posted 07 February 2013 - 08:05 PM
Here is the code.


function fuel()
   if turtle.getFuelLevel() <=20 then
	  turtle.select(16)
	  turtle.refuel(1)
   end
end

--Program Start--

print("Length of trunk: ")
local length = read()

print("Length of branches: ")
local blength = read()

turtle.up()
for z=1,length do
   fuel()
   turtle.dig()
   turtle.forward()
   turtle.digUp()
   turtle.digDown()
end

fuel()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnRight()

for x=1,length do --OP pointed out this line in bold prior to me adding the code tags. -L
  fuel()
  turtle.dig()
  turtle.forward()
  turtle.digUp()
  turtle.digDown()
end


Ok. I am writing this program to dig a branch mine for me with specified trunk length and branch length. I am just gettting started and the second 'for' loop is giving me problems. It appears to me that the second loop is exactly the same as the first other than the change from 'for z=1,length' to 'for x=1,length'. The program is not finished yet because I like to de-bug as I go instead of having lots of errors to deal with at the end. The code here is only to make the 3 high 2 wide <x> length main mine shaft. The loop I am having problems with is the loop that has the turtle return to its starting position. Thanks in advance for the help.

P.S. Line 35 is in bold.


Lyqyd. It was typed over from MC. Not pasted. You were right there was a typo in the line before the error. I didnt close my parenthesis. Thanks!
Edited by
Lyqyd #2
Posted 07 February 2013 - 08:43 PM
Split into new topic.

Is this code copied and pasted, or retyped? If it is retyped, please verify that you copied it correctly, comparing each character at a time between this and the original. I suspect there is a typo in the original (most likely on the line above the error line) that you've corrected when copying it out without realizing you've done so.
trollsama #3
Posted 07 February 2013 - 08:59 PM
is it possible that the lack of spacing between X=1 could be the issue?
I have had errors cause by lack of spacing many times before. and i always make sure to space out anything that is not directly connected. so "for X = 1, length do".
remiX #4
Posted 07 February 2013 - 09:14 PM
is it possible that the lack of spacing between X=1 could be the I ssue?
I have had errors cause by lack of spacing many times before. and i always make sure to space out anything that is not directly connected. so "for X = 1, length do".

No.

When you ask for the lengths. Change read() to tonumber(read()) to convert it into a number.