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

Turtle House program help

Started by faolan89, 24 December 2012 - 09:07 AM
faolan89 #1
Posted 24 December 2012 - 10:07 AM
Ok so i have a simple house building program but i can't figure out how to get the turtle to switch slots when it runs out in one this is my program so far:



local y = 2
local x = 64
turtle.select(1)
turtle.refuel()
turtle.select(2)


function wallBuild() –This builds the wall
for i = 1,4 do
turtle.up()
turtle.placeDown()
x = x-1
if x = 0 then
turtle.select(y=y+1)
end
end
end


function nextColumn() –This starts the next column of the wall
turtle.forward()
for j= 1,4 do
turtle.down()
end
end


for k = 1,10 do
wallBuild()
nextColumn()
end
faolan89 #2
Posted 24 December 2012 - 10:14 AM
I keep getting an error for line 13 it says 'then' expected and i don't know how to fix it
Orwell #3
Posted 24 December 2012 - 10:15 AM
This function advances to the next non-empty slot and asks for a refill when all slots are empty.

function check()
  while true do
    for i=1,16 do
      if turtle.getItemCount(i) > 0 then
   	 return turtle.select(i)
      end
    end
    printError("Out of resources, press a key after a refill.")
    os.pullEvent("key")
  end
end
faolan89 #4
Posted 24 December 2012 - 10:16 AM
Thanks i'll try this out
Orwell #5
Posted 24 December 2012 - 10:24 AM
And to fix the error with your current program, use double '==' instead of '=' in if statements. So change:

if x = 0 then
To:

if x == 0 then