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

[lua] [error] I am getting an error message I cant work out!

Started by aimdog, 12 August 2012 - 07:55 PM
aimdog #1
Posted 12 August 2012 - 09:55 PM
I want to be able to see the state of a nuclear reactor on a large monitor. I am using a thermal monitor and a redstone wire in to the nuclear reactor.to shut it off i also have a button to be used as a master shut off switch they are all connected to the computer but I am now getting an error code it is ""bios:206: [string "qwertyu"] :35: '<eof>' expected"" here is my code

print ("Welcome To Nuclear Reactor Monitor")
while true do
os.pullEvent("redstone")
if redstone.getInput("right") then -- master switch
print ("Starting Neuclear Reactor")
redstone.setOutput("back",true) -- on/off of the reactor
else if redstone.getInput("left") then -- thermal monitor
print("Overheat Detected shuting off reactor for cool down perod")
redstone.setOutput("back",false)
sleep(30)
else if redstone.getInput("right") then
print ("Nuclear Reactor OFF")
redstone.setOutput("back",false)
end
end
end
end
end
Cranium #2
Posted 12 August 2012 - 10:09 PM
You have a few too many ends there. There should be one for the while true do, and the if/elsif statements. Total of two ends.
Pharap #3
Posted 13 August 2012 - 02:43 AM
I want to be able to see the state of a nuclear reactor on a large monitor. I am using a thermal monitor and a redstone wire in to the nuclear reactor.to shut it off i also have a button to be used as a master shut off switch they are all connected to the computer but I am now getting an error code it is ""bios:206: [string "qwertyu"] :35: '<eof>' expected"" here is my code

the following line is wrong:

os.pullEvent("redstone")

you should do e = os.pullEvent() and then if e == "redstone" then –do rest of stuff.

And cranium is right, you need an end for your while and an end for your if, that's only 2 ends, you have 5
Luanub #4
Posted 13 August 2012 - 03:28 AM
I want to be able to see the state of a nuclear reactor on a large monitor. I am using a thermal monitor and a redstone wire in to the nuclear reactor.to shut it off i also have a button to be used as a master shut off switch they are all connected to the computer but I am now getting an error code it is ""bios:206: [string "qwertyu"] :35: '<eof>' expected"" here is my code

the following line is wrong:

os.pullEvent("redstone")

you should do e = os.pullEvent() and then if e == "redstone" then –do rest of stuff.

And cranium is right, you need an end for your while and an end for your if, that's only 2 ends, you have 5

That line is correct. os.pullEvent() contains an internal filter. You can do os.pullEvent("event type you want")

I would only do event = os.pullEvent() if you are working with multiple event types at the same location in the code. Otherwise its cleaner to use the filters.

Edit:
Make sure you are doing elseif and not else if. In Lua it is one word. By doing else if you are starting new if statements and its not going to function as you desire.
Edited on 13 August 2012 - 01:33 AM