Posted 04 August 2012 - 10:11 AM
I've been beating my head with this for quite a bit now but I can't seem to figure it out.
I'm basically trying to have a small display of information with the reactor's state (on or off) and by inputting On or Off, to turn it on or off, obviously.
This is the code. When I run it it returns "reactor:1: attempt to call nil".
What do?
if reactor == false then
reactor="Reactor is Online"
end
if reactor==true then
reactor="Reactor is Offline"
end
shell.run("clear")
local function centertext(text)
local x,y=term.getsize()
local x2,y2=term.getCursorpos()
term.setcursorpos(math.ceil((x/2)-(text:len())))
print(text)
end
centertext("VaultTech205 Control Panel")
centertext("V10.5")
centertext(" ")
centertext("Available Commands")
print(" ")
centertext("Reactor is online : Reactor is Offline")
print(" ")
centertext("Current States")
print(" ")
centertext("Power",reactor)
centertext(reactor)
write("Console: ")
input=read()
if input=="On" then
rs.setoutput("bottom",false)
print("Reactor is now Online.")
end
if input=="Off" then
rs.setoutput("bottom", true)
print("Reactor is now Offline.")
end
sleep(2)
shell.run("clear")
I'm basically trying to have a small display of information with the reactor's state (on or off) and by inputting On or Off, to turn it on or off, obviously.
This is the code. When I run it it returns "reactor:1: attempt to call nil".
What do?
Spoiler
reactor=rs.getoutput("bottom")if reactor == false then
reactor="Reactor is Online"
end
if reactor==true then
reactor="Reactor is Offline"
end
shell.run("clear")
local function centertext(text)
local x,y=term.getsize()
local x2,y2=term.getCursorpos()
term.setcursorpos(math.ceil((x/2)-(text:len())))
print(text)
end
centertext("VaultTech205 Control Panel")
centertext("V10.5")
centertext(" ")
centertext("Available Commands")
print(" ")
centertext("Reactor is online : Reactor is Offline")
print(" ")
centertext("Current States")
print(" ")
centertext("Power",reactor)
centertext(reactor)
write("Console: ")
input=read()
if input=="On" then
rs.setoutput("bottom",false)
print("Reactor is now Online.")
end
if input=="Off" then
rs.setoutput("bottom", true)
print("Reactor is now Offline.")
end
sleep(2)
shell.run("clear")