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

bios:338: [string "startup"]:5: 'then' expected

Started by swid120, 07 May 2013 - 03:22 PM
swid120 #1
Posted 07 May 2013 - 05:22 PM
I´m getting an Error with this code, but why?

mPeripheral=peripheral.wrap("right")
while true do
if mPeripheral.getLevels()<=30
  for i=1,15 do
   turtle.select(i)
   turtle.dropUp()
  end
else
  turtle.select(16)
  mPeripheral.enchant(30)
end
end
Console says:
bios:338: [string "startup"]:5: 'then' expected
but this is a for loop so why then?
Lyqyd #2
Posted 07 May 2013 - 05:51 PM
Split into new topic.

You're getting that error because you're missing a "then". Try adding one to the end of your third line, the one beginning with "if". Be sure to put a space between the end of the conditional and the "then".
digpoe #3
Posted 08 May 2013 - 09:49 AM
IF keywords always work in pairs with the THEN keyword, meaning that you can't just use 'if [condition]' - you have to use 'if [condition] then'