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

= Expected for unknown reason.

Started by MmPMSFmM, 03 August 2013 - 03:49 AM
MmPMSFmM #1
Posted 03 August 2013 - 05:49 AM
I made an attempt on making a simple branch mining code. However there's this problem with the code that it doesn't start up and instead says:
bios:339: [string "branch"]:154: '=' expected
Normally this indicates that on line 154 there is an '=' missing. But there's no reason for an '=' to be on that line, or anywhere else in the code (I think…).

This is the code, line 154 is the last 'else' in the code, just before the end.

Spoiler

--[[According to Benjamin Buford "Bubba" Blue I should make notes.
As always, things may (and probably will) go inevitably wrong. Therefore don't try this at home.
Ductape is my God. Also, I like functions in my functions in my functions in my functions... Yo dawg, I heard you liked functions, so...]]
local length = ...
local aLength = 0
--[[Source for function refuel(): tunnel, a standard CC mining turtle program. Therefore I take no credit for this function.
It refuels :o/>/>]]
local function refuel()
local fuelLevel = turtle.getFuelLevel()
if fuelLevel == "unlimited" or fuelLevel > 0 then
  return
end
print( "Attempting to Refuel..." )
local function tryRefuel()
  for n=1,16 do
   if turtle.getItemCount(n) > 0 then
	turtle.select(n)
	if turtle.refuel(1) then
	 turtle.select(1)
	 print( "Refuelling successful!" )
	 return true
	end
   end
  end
  turtle.select(1)
  return false
end

if not tryRefuel() then
  print( "Add more fuel to continue." )
  while not tryRefuel() do
   sleep(1)
  end
  print( "Resuming Tunnel." )
end
end
--Digs forward
local function frontDig()
while turtle.detect() do
  turtle.dig()
  sleep(0.25)
end
end
--Digs up
local function upDig()
while turtle.detectUp() do
  turtle.digUp()
  sleep(0.25)
end
end
--Digs down
local function downDig()
while turtle.detectDown() do
  turtle.digDown()
  sleep(0.25)
end
end
--Goes forward
local function frontGo()
refuel()
frontDig()
while turtle.attackUp() do
  turtle.attackUp()
  sleep(0.25)
end
turtle.forward()
end
--Goes up
local function upGo()
refuel()
upDig()
while turtle.attackUp() do
  turtle.attackUp()
  sleep(0.25)
end
turtle.up()
end
--Goes down
local function downGo()
refuel()
downDig()
while turtle.attackDown() do
  turtle.attackDown()
  sleep(0.25)
end
turtle.down()
end
--Makes trunk
local function trunkMine()
upDig()
turtle.turnLeft()
frontDig()
upGo()
frontDig()
turtle.turnLeft()
turtle.turnLeft()
frontDig()
downGo()
frontDig()
aLength = aLength + 1
if aLength % 10 then
  print( "The branch mine is now " , aLength , " blocks long." )
end
end
--Makes branch
local function branchMine()
local function branch()
  for n=1,5 do
   frontGo()
   upDig()
  end
end

local function move()
  turtle.turnLeft()
  turtle.turnLeft()
  for n=1,6 do
   frontGo()
  end
end

frontGo()
branch()
move()
frontGo()
branch()
move()
end
--Combines the branch and the trunk
local function treeMine()
for n=1,4 do
  trunkMine()
  turtle.turnLeft()
  if aLength ~= length then
   frontGo
  else
   print( "Finished branch mine." )
   return true
  end
end
branchMine()
turtle.turnLeft
end
Bubba #2
Posted 03 August 2013 - 10:30 AM
Split into new topic.
Bubba #3
Posted 03 August 2013 - 10:38 AM
Typically, when you have an = expected error, you have misspelled something or left the parentheses off a function execution. In your case, look just above that else.

frontGo
Looks like it's the latter :)/>
MmPMSFmM #4
Posted 03 August 2013 - 01:52 PM
Typically, when you have an = expected error, you have misspelled something or left the parentheses off a function execution. In your case, look just above that else.

frontGo
Looks like it's the latter :)/>
Thanks! This worked and solved my problem completely. Also thanks for pointing out the things about the = expected error… It's a shame I forget parenthesis so often…