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

attempt to call nil

Started by SeeJay, 23 December 2012 - 08:31 AM
SeeJay #1
Posted 23 December 2012 - 09:31 AM
Sorry if this is a stupid question, but I am new to programming and even newer to Lua

Here's my code


print("How High?")
h = tonumber(read())
	 turtle.goUp(h)
	 turtle.select(1)
	 if turtle.getItemCount(1) < 1 then
		  turtle.select(2)
	 end
	 turlte.place()
print("Your Platform is complete")

it gives me an attempt to call nil error on the line with

turtle.goUp(h)


any help would be appreciated, I just can't figure out what I am doing wrong, I come from a Java background, so some of this syntax is somewhat frustrating. This is probably really simple, I just want to start learning some Lua, because this mod is really interesting
Doyle3694 #2
Posted 23 December 2012 - 09:32 AM
first, it's turtle.up().

Second, turtle.up() dont accept any arguments, so running it many times will make you have to use a for loop.
SeeJay #3
Posted 23 December 2012 - 09:34 AM
Oh wow, I'm feel stupid now, thank you so much, I probably should have noticed that… I guess I shouldn't assume things have arguements

Thanks for the quick response!