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

Error [Need Help]

Started by Popeye, 16 April 2013 - 06:24 AM
Popeye #1
Posted 16 April 2013 - 08:24 AM
Hello Everyone,

I'm upgrading my Diggy Turtle (DDP)

And I have an Error:
bios:337: [string "Diggy"]:14: 'then' expected

Code:


print('Working!')

for i = 1,21 do

  turtle.refuel(1) -- Refueling the Turtle

  turtle.dig()
  turtle.forward()

  turtle.dig()
  turtle.forward()
end

if inventory = 2, 4 then
  turtle.select(i)
  turtle.dropdown()
end

turtle.turnRight()
turtle.turnRight()

turtle.forward()
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward() 
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()

turtle.turnLeft()
turtle.turnLeft()

print('Done')

Does anyone know the Solution?
SadKingBilly #2
Posted 16 April 2013 - 08:31 AM
The comparison operator to check for equivalence is "==", not "=". Also, commas don't work in if-statements (as far as I know, anyway). The line "if inventory = 2, 4 then" needs to be "if inventory == 2 or inventory == 4 then".

If that's what you were trying to do. I'm actually not sure what you were trying to do.
Popeye #3
Posted 16 April 2013 - 08:36 AM
I'm trying to make it so that when the Turtle Return's to its Original spot it will put the Items from Slot 2 - 4 into the Chest behind it.
Bubba #4
Posted 16 April 2013 - 09:21 AM
You have a lot of unecessary code in there.


--Replace this:
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()

--with this:
for forward=1,4 do
  turtle.forward()
end
Popeye #5
Posted 16 April 2013 - 09:37 AM
Thank's Bubba, That has been Implemented.

I also have another Error:
Diggy:19: attempt to call nil

Code:


print('Working!')

for i = 1,21 do

  turtle.refuel(1) -- Refueling the Turtle

  turtle.dig()
  turtle.forward()

  turtle.dig()
  turtle.forward()
end

turtle.turnRight()
turtle.turnRight()

for forward = 1,30 do
  turtle.forward()
end

for inventory = 2,4 do
  turtle.select(inventory)
  turtle.dropdown()
end

turtle.turnLeft()
turtle.turnLeft()

print('Done')

Any Help with this?
Bubba #6
Posted 16 April 2013 - 09:41 AM
You put "turtle.dropdown()"

It should be "turtle.dropDown()"
Popeye #7
Posted 16 April 2013 - 09:46 AM
You put "turtle.dropdown()"

It should be "turtle.dropDown()"

Okay, Thanks Bubba! You got it Working for me. There will be an Update for the DDT Tomorrow if you want to check it out.