Jump to content




Deleted


4 replies to this topic

#1 J-Nutz

  • Members
  • 14 posts

Posted 05 October 2013 - 02:13 PM

Deleted. Can't bear the noobiness that is being portrayed by my self in this post.

Edited by J-Nutz, 20 May 2014 - 03:02 PM.


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 05 October 2013 - 02: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.

#3 bobmandude9889

  • Members
  • 21 posts

Posted 05 October 2013 - 08: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


#4 jamd315

  • Members
  • 24 posts
  • Location(Insert egocentric quote here)

Posted 05 October 2013 - 08:22 PM

When comparing two things eg. function and boolean, use == to return true instead of = to set a value.

#5 jay5476

  • Members
  • 289 posts

Posted 05 October 2013 - 08: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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users