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

Expecting "then"

Started by sight19, 27 February 2012 - 09:28 AM
sight19 #1
Posted 27 February 2012 - 10:28 AM
I really am a beginner, so probably there are some mistakes. It says "expecting "then"" at line 12, though there already is a then.
Can someone figure out please?

print("checking data")
sleep(0.5)
print("checking data.")
sleep(0.5)
print("checking data..")
sleep(0.5)
print("checking data...")
sleep(0.5)
redstone.getInput(a,;)/>/>
if b==true then
clearScreen()
if a="right" then
print("Reactor battery full")
elseif a="left" then
print("Generator battery full")
end
if read()="alarm" then
redstone.setOutput("back",true)
elseif read()="alarm off" then
redstone.setOutput("back",false)
elseif read()="reboot" then
os.reboot()
end
else
print("no battery full")
if read()="alarm" then
redstone.setOutput("back",true)
elseif read()="alarm off" then
redstone.setOutput("back",false)
elseif read()="reboot" then
os.reboot()
end
end
Chub1337 #2
Posted 27 February 2012 - 10:33 AM
You're not using == for some of your if statements. (pretty much every single one except the first one). Try adding those ='s and see if it works.
Advert #3
Posted 27 February 2012 - 11:37 AM
You're not using == for some of your if statements. (pretty much every single one except the first one). Try adding those ='s and see if it works.

To be more precise, you need to use == to compare equals; = (single = sign) will assign; so once you fix this (and the other cases) it'll work:

if a="right" then
--should be:
if a=="right" then