Jump to content




turtle:22: expected number.


  • You cannot reply to this topic
3 replies to this topic

#1 blipman17

  • Members
  • 92 posts

Posted 01 April 2014 - 08:32 AM

[solved]


i'm having an error in my program which I can't track down.
Can anyone help me?
the error is:
turtle:22: expected number
and the code:
quarrylenght=10
conduit=1
quarry=2
enderchest=3
waste1=4
waste2=5
fuel=16
quarrytime=10
signal=15
function wastereduction()
if turtle.getItemCount(waste1)>0 then turtle.select(waste1) turtle.dropUp() end
if turtle.getItemCount(waste2)>0 then turtle.select(waste2) turtle.dropUp() end
end
function forward()
-- getting in position
turtle.select(enderchest)
turtle.dig()
turtle.forward()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnRight()
turtle.turnRight()
-- getting the complete front row
local counter = quarrylenght-1
  while counter>0 do
   counter=counter-1
   turtle.select(enderchest)
   turtle.dig()
   turtle.select(quarry)
   turtle.digDown()
   turtle.forward()
  end
-- getting in posiotion for the conduit row
turtle.turnRight()
turtle.forward()
turtle.select(conduit)
turtle.digDown()
turtle.down()
turtle.turnRight()
-- getting the row of conduits
local counter= quarrylenght-1
  while counter>0 do
   counter=counter-1
   turtle.dig()
   turtle.forward()
  end
-- end of the cleanup, start of the placement
turtle.turnRight()
turtle.forward()
turtle.select(waste1)
turtle.dig()
turtle.forward()
turtle.turnRight()
-- going to do the clearing of the next row and the placement of the ender chests.
local counter = quarrylenght
  while counter>0 do
   counter=counter-1
	repeat
	 turtle.select(waste2)
	 turtle.digUp()
	 turtle.select(enderchest)
	 turtle.placeUp()
	until turtle.compareUp(enderchest)==true
	wastereduction()
   -- the forward part, doesn't go of for the last time
	while counter>1 do
	 turtle.select(wase1)
	 turtle.dig()
	  while turtle.forward()==false do
	   sleep(4)
	   turtle.select(waste1)
	   turtle.dig()
	  end
	end
  end
-- getting in place for the placement of quarry's and conduits
turtle.turnLeft()
turtle.back()

end
forward()
if it does some weird movement, it is an unfinished quarry turtle.

Edited by blipman17, 01 April 2014 - 11:44 AM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 01 April 2014 - 08:49 AM

At one point when calling turtle.select(), you mispell "waste1" as "wase1". This crashes the turtle API as you end up passing it nil instead of a number.

#3 blipman17

  • Members
  • 92 posts

Posted 01 April 2014 - 09:10 AM

Thanx, but shouldn't that give something like "couldn't index a nil value"?


Qnd how do you mark a topic as solved?

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 01 April 2014 - 09:26 AM

View Postblipman17, on 01 April 2014 - 09:10 AM, said:

Thanx, but shouldn't that give something like "couldn't index a nil value"?

Since the error is occurring based on the way in which the turtle API is attempting to use the value you gave it, it's difficult to predict what the error will be in cases such as this. Just because a fault involved an invalid use of nil, doesn't mean that use involved indexing it!

Generally speaking, if you get an error message telling you there's a fault in an API you're using (as opposed to an error telling you where and how you called an API function incorrectly), then you need to proof-read every instance where you called a function of that API to track it down. Knowing how far your script progressed before triggering the crash can allow you to eliminate a whole bunch of calls right off the bat.

ComputerCraft 1.6 should be a bit better about giving more informative errors in cases such as this.

View Postblipman17, on 01 April 2014 - 09:10 AM, said:

Qnd how do you mark a topic as solved?

You could edit your first post to state as much, if you're so inclined. There's really no need.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users