4 posts
Posted 04 January 2013 - 11:05 AM
Here is my program:
function doorTrue()
print("Opening Door")
redstone.setOutput("left",true)
sleep(7)
end
function doorFalse()
print("Closing Door")
redstone.setOutput("left",false")
end
on == true
off == false
write "On/Off: "
if input = true then doorTrue()
if input = false then doorFalse()
end
Now, when I try to run this program, it gives me a [string "door"]:13: 'then' expected. I have no idea what I have to do there. Then sometimes, it gives me an error saying [string "door"]:10: "=" expected, but I know that I need on to have to value of true, so I don't change it. And, finally, I sometimes get the error [string "door"]:5: <eof> expected. I don't even know what eof means. Can anyone help?
8543 posts
Posted 04 January 2013 - 11:16 AM
You have comparison and assignment backwards. Where you have ==, it should be = and where you have =, it should be ==.
264 posts
Location
Where you aren't
Posted 04 January 2013 - 11:18 AM
Using = is setting a variable
Using == or === is comparing a variable to another variable.
You either need another 'end' or a 'elseif' in place of the second 'if'
You are checking the 'input' variable but never declaring it
The write function needs (), this isn't PHP.
EDIT: Damn you ninja posts…
25 posts
Location
A flatland world with 100's of computers and a village that was covered with lava with a parkour course about it; Minecraftia.
Posted 04 January 2013 - 11:19 AM
function doorTrue()
print("Opening Door")
redstone.setOutput("left", true)
sleep(7)
end
function doorFalse()
print("Closing Door")
redstone.setOutput("left",false")
end
input = read()
write ("On/Off: ")
if input == "On" then
doorTrue()
elfeif input == "Off" then
doorFalse()
end
Your code should work fine now, try that^
25 posts
Location
A flatland world with 100's of computers and a village that was covered with lava with a parkour course about it; Minecraftia.
Posted 04 January 2013 - 11:23 AM
Using = is setting a variable
Using == or === is comparing a variable to another variable.
You either need another 'end' or a 'elseif' in place of the second 'if'
You are checking the 'input' variable but never declaring it
The write function needs (), this isn't PHP.
EDIT: Damn you ninja posts…
You ninja posted me brah.
2088 posts
Location
South Africa
Posted 04 January 2013 - 08:27 PM
The write function needs (), this isn't PHP.
It doesn't need the ()