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

Programing Help

Started by MrCobraFlame, 17 March 2014 - 06:48 AM
MrCobraFlame #1
Posted 17 March 2014 - 07:48 AM
Im trying to make a code for turtles that can make a platform of "l" length and "w" width. Please keep in mind im not a coder whatsoever and my code is probably mediocre at best. I keep getting an error when running saying that its expecting a "" string:"Platform":50 expecting "=" ""but I have no clue why its wanting = or where.  

l = 15

w = 15

e = l/2

i = 0

 

function MaterialsNeeded()

  print(l*w)

end

 

function Seti()

  print("From")

  if l%2 == 1  then

    i = .5

    print(i)

  else

    i = 0

    print(i)

  end

   

 

function Start()

  turtle.forward()

  DetectMaterial()

  turtle.placeDown()

  turtle.turnRight()

  print("To")

  print(e)

  print(" ")

  print(" ")

  repeat

    turtle.forward()

    DetectMaterial()

    turtle.placeDown()

    sleep(1)

    i = i + 1

    sleep(1)

    print(i)

  until i == e

  i = 0

end

 

function ComeBack()

  turtle.turnLeft()

  turtle.forward()

  turtle.turnLeft()

  DetectMaterial()

  turtle.placeDown()

  repeat

   turtle.forward

   DetectMaterial()

   turtle.placeDown()

   i = i + 1

  until i == l

  i = 0

  end

end

 

function GoBack()

  turtle.turnRight()

  turtle.forward()

  DetectMaterial()

  turtle.placeDown()

  turtle.turnRight()

  repeat

    turtle.forward()

    DetectMaterial()

    turtle.placeDown()

    i = i + 1

  until i = l

  i = 0

end

 

function DetectMaterial()

  if turtle.getItemCount(1) => 0 then

    turtle.select(1)

    end

  elseif turtle.getItemCount(2) >= 0 then

    turtle.select(2)  

    end

  elseif turtle.getItemCount(3) >= 0 then

    turtle.select(3)

    end

  elseif turtle.getItemCount(4) >= 0 then

    turtle.select(4)

    end

  elseif turtle.getItemCount(5) >= 0 then

    turtle.select(5)

    end

  elseif turtle.getItemCount(6) >= 0 then

    turtle.select(6)

    end

  elseif turtle.getItemCount(7) >= 0 then

    turtle.select(7)

    end

  elseif turtle.getItemCount(8) >= 0 then

    turtle.select(8)

    end

  elseif turtle.getItemCount(9) >= 0 then

    turtle.select(9)

    end

  elseif turtle.getItemCount(10) >= 0 then

    turtle.select(10)

    end

  elseif turtle.getItemCount(11) >= 0 then

    turtle.select(11)

    end

  elseif turtle.getItemCount(12) >= 0 then

    turtle.select(12)

    end

  elseif turtle.getItemCount(13) >= 0 then

    turtle.select(13)

    end

  elseif turtle.getItemCount(14) >= 0 then

    turtle.select(14)

    end

  elseif turtle.getItemCount(15) >= 0 then

    turtle.select(15)

    end

  else turtle.getItemCount(16) >= 0 then

    turtle.select(16)

  end

end  

 

function Platform()

  MaterialsNeeded()

  Start()

  f = 0

  repeat

    ComeBack()

    GoBack()

    f = f + 1

  until f = w

end
theoriginalbit #2
Posted 17 March 2014 - 01:13 PM
your problem is in your repeat loop. all conditionals must be == not =
change until i = l to say until i == l also in the future please use [code][/code] tags around your code and/or upload it to pastebin.
Edited on 17 March 2014 - 12:13 PM
MrCobraFlame #3
Posted 17 March 2014 - 08:04 PM
So i changed the code based on your feedback. Fixed the i == l and added a sleep(1) between the if/elseif segment however its giving me the same error message.

The current iteration of the code is www.pastebin.com/xnvxYtTu
I am sorry about the code mishap last time.
Lyqyd #4
Posted 17 March 2014 - 08:41 PM
I'd imagine the error now says line 60, not line 50. You are missing the parentheses on line 59.