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

Deleted

Started by J-Nutz, 05 October 2013 - 01:13 PM
J-Nutz #1
Posted 05 October 2013 - 03:13 PM
Deleted. Can't bear the noobiness that is being portrayed by my self in this post.
Edited on 20 May 2014 - 02:02 PM
Lyqyd #2
Posted 05 October 2013 - 03:47 PM
Split into new topic.

Check out the Lua Reference Manual, the lua-users wiki, or the PIL docs to see how to actually use if statements.
bobmandude9889 #3
Posted 05 October 2013 - 09:13 PM

function check()   --first line
  for i = 16, 3, -1 do turtle.compareTo(1) if = true then do turtle.dropUp()   --saplings
   for o = 16, 5, -1 do turtle.compareTo(3) if == true do turtle.turnLeft() turtle.drop()   --bonemeal
	for u = 14, 1, -1 do turtle.compareTo(15) if == true do turtle.turnRight() turtle.drop()   --wood
	end
   end
  end
end

You are not using if statements correctly. Instead of doing

turtle.compareTo(1) if = true then do turtle.dropUp()

You should do


if turtle.compareTo(1) then
  turtle.dropUp()
end
jamd315 #4
Posted 05 October 2013 - 09:22 PM
When comparing two things eg. function and boolean, use == to return true instead of = to set a value.
jay5476 #5
Posted 05 October 2013 - 09:27 PM
more explaination:
if statements work like this

if <condition> then
and for comparing to things you need '=='

if 1+1 == 2 then
^ would be a valid if statement comparing 1+1 to 2 if there the same(comparison is true) continue code
now how this works

if turtle.compareTo(1) then
is turtle.compareTo(1) is a function which returns a boolean(either true or false) so if it returns true its basiclly like saying

if true then
and if the comparision is true it will continue code

you can also do stuff like 'not' 'or' 'and' 'else' elseif' but i recommend the reference manual or PIL