 
                
                7 posts
                
             
            
                Posted 02 May 2013 - 02:23 AM
                
function placer()
    while true do
    turtle.place()
    if turtle.getItemCount(1) <=5  then
    for slot=2,16 do
    turtle.transferTo(1, 3)
    end
    if turtle.back() == false then
    layer()
    rotate()
    end
    end
    end
can Lua tell which end goes with what or can i specify?
I didn't think spacing mattered for code..
Cheers!
 
         
        
        
            
            
                
                     
                
                671 posts
                
                    
                        Location
                        That place over there. Y'know. The one where I am.
                    
                
             
            
                Posted 02 May 2013 - 02:32 AM
                Yes, Lua will be able to tell which end goes with what. but to make it look better, make it:
function placer()
  while true do
    turtle.place()
    if turtle.getItemCount(1) <=5  then
      for slot=2,16 do
        turtle.transferTo(1, 3)
      end
      if turtle.back() == false then
        layer()
        rotate()
      end
    end
  end
end
You may have gotten an error with your previous code because you missed an end to close:
if turtle.getItemCount(1) <= 5 then
 
         
        
        
            
            
                
                     
                
                7 posts
                
             
            
                Posted 02 May 2013 - 02:56 AM
                Thanks :)/>
Do I need an 'end' for else statements or does that come within the if statement?
                
             
         
        
        
            
            
                
                     
                
                7508 posts
                
                    
                        Location
                        Australia
                    
                
             
            
                Posted 02 May 2013 - 03:15 AM
                Do I need an 'end' for else statements or does that come within the if statement?
if statement syntax
if <condition> then
  -- code
end
if … else statement syntax
if <condition> then
  -- code
else
  -- code
end
if … elseif statement syntax
if <condition> then
  -- code
elseif <condition> then
  -- code
end
if … elseif … else statement syntax
if <condition> then
  -- code
elseif <condition> then
  -- code
else
  -- code
end
so as you can see only one end is required to close the statement.