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

[Erorr] bios :338: [string "Excavate"]:39: '<name>' expected

Started by Apfeldstrudel, 22 March 2013 - 10:25 AM
Apfeldstrudel #1
Posted 22 March 2013 - 11:25 AM
Hello :D/> i made an excavate program(NOT DONE!) to dig out a specified area but on the for loop on rown 39 i keep getting an error.




NOTE: I FIXED IT :D/>

size=0
deep=0
function getInfo()
  term.clear()
  term.setCursorPos(1,1)
  print("What size?")
  size=read()
  if size<= 4 then
	print("Please use a number greater than 4")
	getInfo()
  end
  size = math.ceil(size)
  if size % 2 == 1 then
	print("Please use a number divisible by 2")
	getInfo()
  end
  term.clear()
  term.setCursorPos(1,1)
  print("How deep?")
  deep=read()
end
getInfo()
term.clear()
term.setCursorPos(1,1)
print("Excavating a "..size.." x "..size.." x "..deep.." area.")
temp=read()
function refuel()
  if turtle.getFuelLevel()< 50 then
	turtle.select(1)
	while turtle.refuel() == false do
	  print("I am out o fuel! Feed it in slot 1 and press enter")
	
	  temp = read()
	end
  end
end
function forw(times)
  for 1, times do
	turtle.dig()
	refuel()
	turtle.forward()
  end
end
function left(times)
  for 1, times do
	turtle.turnLeft()
	refuel()
  end
end
function right(times)
  for 1, times do
	turtle.turnRight()
	refuel()
  end
end
for 1, size/2 - 1 do
  forw(size-1)
  left(1)
  forw(1)
  left(1)
end

Please help D;
Lyqyd #2
Posted 22 March 2013 - 03:15 PM
Split into new topic.

For loops need a variable name. Try changing the beginning of that for loop to `for i = 1, size/2 - 1 do`
Apfeldstrudel #3
Posted 22 March 2013 - 08:22 PM
Thanks :D/> working fine so far

EDIT: New problem "attempting to compare number with string expected, got number"
EDIT2: Fixed, asked a guy on the server and he said i should do size=tonumber(read)) and it works perfectly :D/>


i keep on mixing up c++,lua and java…. *sadface*
Engineer #4
Posted 22 March 2013 - 08:39 PM
Thanks :D/> working fine so far

EDIT: New problem "attempting to compare number with string expected, got number"

i keep on mixing up c++,lua and java…. *sadface*
On what line are you getting this error?