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

[Question] whats wrong with this code

Started by smurfofiel, 20 January 2013 - 11:30 AM
smurfofiel #1
Posted 20 January 2013 - 12:30 PM
local engines = false

print("engines on or off?")
question == io.read()
while true do
if question == on then
engines = true
term.clear()
break
else
if question == off then
engines = false
term.clear()
break
else
print("You need to say ON or OFF!")
end
end
end

edit: this is the error:
bios:388: [string "engines"] :4: '=' expected
TheOddByte #2
Posted 20 January 2013 - 12:32 PM
Well first off all print Your error,
And You need to call on and off as strings like this:

"on"
"off"
theoriginalbit #3
Posted 20 January 2013 - 12:35 PM
Please don't double post, it won't get you help any quicker… I have answered your question in the other topic you posted it…

Also this IS the correct place to post issues like this… not in "Programs" that area is for completed code…
Edited on 20 January 2013 - 11:36 AM
TheOddByte #4
Posted 20 January 2013 - 01:15 PM
Please don't double post, it won't get you help any quicker… I have answered your question in the other topic you posted it…

Also this IS the correct place to post issues like this… not in "Programs" that area is for completed code…
You mean that he posted like the exactly same thing before?
theoriginalbit #5
Posted 20 January 2013 - 01:17 PM
Please don't double post, it won't get you help any quicker… I have answered your question in the other topic you posted it…

Also this IS the correct place to post issues like this… not in "Programs" that area is for completed code…
You mean that he posted like the exactly same thing before?
He posted it here http://www.computercraft.info/forums2/index.php?/topic/9533-what-is-wrong-need-help/
ChunLing #6
Posted 20 January 2013 - 05:48 PM
Generally, you want to tell us what is wrong with the code…what happens when you run it that differs from what you thought would happen (often this include the issuance of an error message).

We then are able to tell you why it is wrong, and perhaps how to fix it to do what you want.

In this case, with the information given, I'm going to say that there is nothing wrong with this code :)/>
smurfofiel #7
Posted 20 January 2013 - 11:31 PM
this is the error:
bios:388: [string "engines"] :4: '=' expected
sjele #8
Posted 20 January 2013 - 11:45 PM
You set a variable with = and compare to values with ==.
Line 4 should be question = io.read()
smurfofiel #9
Posted 21 January 2013 - 11:19 AM
You set a variable with = and compare to values with ==.
Line 4 should be question = io.read()
ooh jeah i am stupid that i dont saw that thank you very much :)/>
theoriginalbit #10
Posted 21 January 2013 - 12:01 PM
Line 4 should be question = io.read()
Doesn't need to be… read() does the same…
remiX #11
Posted 21 January 2013 - 06:17 PM
Line 4 should be question = io.read()
Doesn't need to be… read() does the same…

Yeah but he has question == io.read()
ChunLing #12
Posted 21 January 2013 - 10:07 PM
Of course, we're moving towards the much worse behavior of continuously printing "You need to say ON or OFF!" until the computer is stopped for failure to yield.

But hey, maybe that's intentional? ;)/>
remiX #13
Posted 22 January 2013 - 01:22 AM
Of course, we're moving towards the much worse behavior of continuously printing "You need to say ON or OFF!" until the computer is stopped for failure to yield.

But hey, maybe that's intentional? ;)/>

Haha, only saw that now. It's hard to see if you're not really concentrating because of no code tags or indentation :P/>