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

whats wrong with my code

Started by Greenwolf25, 03 February 2013 - 01:50 PM
Greenwolf25 #1
Posted 03 February 2013 - 02:50 PM
Title whats wrong with my code

Line 23 keeps saying it needs a equles

--Setup
rednet.open ("right")
print (turtle.getFuelLevel())
print (os.getComputerLabel())
print (os.getComputerID())
local Y = 81
--Code
if Y > 7 then
turtle.digDown()
turtle.attackDown()
turtle.attackDown()
turtle.attackDown()
turtle.attackDown()
turtle.down()
Y = Y+1
turtle.select(16)
itemc = turtle.getItemCount()
  if itemc > 0 then
  turtle.turnRight()
  turtle.turnRight()
  turtle.select(1)
  turtle.place
  turtle.select(2)
  turtle.drop()
  turtle.select(3)
  turtle.drop()
  turtle.select(4)
  turtle.drop()
  turtle.select(5)
  turtle.drop()
  turtle.select(6)
  turtle.drop()
  turtle.select(7)
  turtle.drop()
  turtle.select(8)
  turtle.drop()
  turtle.select(9)
  turtle.drop()
  turtle.select(10)
  turtle.drop()
  turtle.select(11)
  turtle.drop()
  turtle.select(12)
  turtle.drop()
  turtle.select(13)
  turtle.drop()
  turtle.select(14)
  turtle.drop()
  turtle.select(15)
  turtle.drop()
  turtle.select(16)
  turtle.drop()
  rednet.send (144, "Drop")
  turtle.dig
  turtle.turnRight
  turtle.turnRight
  end
else
while up > 0 then
  local up = 75
  if up > 0 then
  turtle.up
  up = up-1
  end
else
  turtle.dig
  turtle.forward
  end
end
Edited by
Cranium #2
Posted 03 February 2013 - 03:02 PM
Topic split to new post. Next time with your code, try putting it in code tags, like this:

Kingdaro #3
Posted 03 February 2013 - 03:05 PM
Lines like this:

turtle.place
turtle.dig
turtle.turnLeft

They need to have brackets after them.

turtle.place()
turtle.dig()
turtle.turnLeft()

Also, please, for the love of god, instead of this:

  turtle.select(1)
  turtle.place()
  turtle.select(2)
  turtle.drop()
  turtle.select(3)
  turtle.drop()
  turtle.select(4)
  turtle.drop()
  turtle.select(5)
  turtle.drop()
  turtle.select(6)
  turtle.drop()
  turtle.select(7)
  turtle.drop()
  turtle.select(8)
  turtle.drop()
  turtle.select(9)
  turtle.drop()
  turtle.select(10)
  turtle.drop()
  turtle.select(11)
  turtle.drop()
  turtle.select(12)
  turtle.drop()
  turtle.select(13)
  turtle.drop()
  turtle.select(14)
  turtle.drop()
  turtle.select(15)
  turtle.drop()
  turtle.select(16)
  turtle.drop()

Do this:

turtle.select(1)
turtle.place()
for i=2, 16 do
  turtle.select(i)
  turtle.drop()
end
Greenwolf25 #4
Posted 03 February 2013 - 03:27 PM
Ok now it saying it was expecting and "=" on line 37

--Setup
rednet.open ("right")
print (turtle.getFuelLevel())
print (os.getComputerLabel())
print (os.getComputerID())
local Y = 81
--Code
if Y > 7 then
turtle.digDown()
turtle.attackDown()
turtle.attackDown()
turtle.attackDown()
turtle.attackDown()
turtle.down()
Y = Y+1
turtle.select(16)
itemc = turtle.getItemCount()
  if itemc > 0 then
  turtle.turnRight()
  turtle.turnRight()
  turtle.select(1)
  turtle.place()
  for i=2, 16 do
   turtle.select(i)
   turtle.drop()
   end
  rednet.send (144, "Drop")
  turtle.dig()
  turtle.turnRight()
  turtle.turnRight()
  end
else
local x = 75
while up > 0 do
  if x > 0 then
  turtle.up
  x = x-1
  end
else
  turtle.dig
  turtle.forward
  end
end
Kingdaro #5
Posted 03 February 2013 - 04:14 PM
I don't want to seem like a jerk, but please at least try to figure out the problem before pasting the code here, as I've already stated what it was.

Line 36 is missing brackets, as is line 40 and 41. Also, while loops have no "else". The while loop at the end should look like this:

  while up > 0 do
    if x > 0 then
      turtle.up()
      x = x-1
    end
  end
  turtle.dig()
  turtle.forward()
theoriginalbit #6
Posted 03 February 2013 - 04:23 PM
in addition to what Kingdaro has stated.

if the code provided is all of it, this loop will have problems as you have never stated what up is, and if you did you never change up inside the loop, so it would always run.

while up > 0 do


EDIT: Also this

turtle.digDown()
turtle.attackDown()
turtle.attackDown()
turtle.attackDown()
turtle.attackDown()
turtle.down()
if I understand exactly why you are doing this, then this would be better

turtle.digDown()
while not turtle.down() do
  turtle.attackDown()
end
Edited on 03 February 2013 - 03:26 PM
Greenwolf25 #7
Posted 03 February 2013 - 08:10 PM
ok thanks Im tired so I'm having trouble.