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

[error] bios:206: '=' expected

Started by wrothmonk, 05 January 2013 - 08:02 PM
wrothmonk #1
Posted 05 January 2013 - 09:02 PM
I'm trying to make a turtle that will move around via rednet commands and plant tnt mines that can be triggered by a rednet message.

When I attempt to run the program that starts the turtle receiving rednet commands and acting on them I get this error message:

bios:206: [string "mine_turtle"]:33:
'=' expected

I'm assuming that for some reason it is expecting an = sign on line 33 somewhere but I dont see why when the normal syntax for that command doesn't require an = and it has been used almost exactly other times in the code with no problem.

Code:
Spoiler

while true do
function dig()
  turtle.digDown()
  turtle.suckDown()
  turtle.down()
  turtle.digDown()
  turtle.suckDown()
  turtle.down()
  turtle.select(2)
  turtle.placeUp()
  turtle.digDown()
  turtle.select(1)
  turtle.placeDown()
end
function fire()
  redstone.setOutput("bottom", true)
end
function forward()
  turtle.forward()
end
function backward()
  turtle.back()
end
function left()
  turtle.turnLeft()
end
function right()
  turtle.turnRight()
end
function up()
  turtle.up()
end
function down()
  turtle.down()
end
rednet.open("right")
local event, p1, p2, p3, p4, p5 = os.pullEvent()
if event == "rednet_message: then
  if p1 == 0 then
   if p2 == "dig" then
	dig()
   elseif p2 == "forward" then
	 forward()
   elseif p2 == "backward" then
	backward()
   elseif p2 == "left" then
	left()
   elseif p2 == "right" then
	right()
   elseif p2 == "up" then
	up()
   elseif p2 == "down" then
	down()
   elseif p2 == "fire" then
	fire()
   end
  else
  end
else
end
end
Luanub #2
Posted 05 January 2013 - 09:11 PM
When doing comparisons is == to assign values its =

So on this line

if event = rednet_message then

--it should be
if event == "rednet_message" then --the event type is also a string so you need to wrap it in quotes
Doyle3694 #3
Posted 05 January 2013 - 09:13 PM
if event == "rednet_message" then
Rednetmessage is a string, and as you might guess, a = was expected, you missed one
wrothmonk #4
Posted 05 January 2013 - 09:16 PM
ok fixed that but its still giving the same error Figured out why the error was still going, I misspelled function.
Its working fine now
Luanub #5
Posted 05 January 2013 - 09:21 PM
You have all of your functions inside of the while loop. Move the functions outside of the loop.

Spoiler

function dig()
  turtle.digDown()
  turtle.suckDown()
  turtle.down()
  turtle.digDown()
  turtle.suckDown()
  turtle.down()
  turtle.select(2)
  turtle.placeUp()
  turtle.digDown()
  turtle.select(1)
  turtle.placeDown()
end
function fire()
  redstone.setOutput("bottom", true)
end
function forward()
  turtle.forward()
end
function backward()
  turtle.back()
end
function left()
  turtle.turnLeft()
end
function right()
  turtle.turnRight()
end
function up()
  turtle.up()
end
function down()
  turtle.down()
end
rednet.open("right")

while true do
local event, p1, p2, p3, p4, p5, = os.pullEvent()
if event == "rednet_message: then  -- you have a : should be a "
  if p1 == 0 then
   if p2 == "dig" then
		dig()
   elseif p2 == "forward" then
		 forward()
   elseif p2 == "backward" then
		backward()
   elseif p2 == "left" then
		left()
   elseif p2 == "right" then
		right()
   elseif p2 == "up"
		up()
   elseif p2 == "down" then
		down()
   elseif p2 == "fire" then
		fire()
   end
  else -- you also don't need this remove it
  end
else  -same here remove it
end
end


See comments in the code
Edited on 05 January 2013 - 08:23 PM