Posted 01 February 2015 - 12:35 PM
Hello pro's,
I'm pretty much a noob in programming so i think it is just me. but i'm trying to make a status screen for my reactor. which has a nice startup screen in which i check if the reactor is connect. it seems logical that i use getConnected for this because it returns true if a reactor is connected. but if i disconnect the reactor i just keep getting the error: attempt to index? (a nil value)
this is the code i've created thus far and with the reactor connected is works.
is there a way i can prevent that error message from showing ?
I'm pretty much a noob in programming so i think it is just me. but i'm trying to make a status screen for my reactor. which has a nice startup screen in which i check if the reactor is connect. it seems logical that i use getConnected for this because it returns true if a reactor is connected. but if i disconnect the reactor i just keep getting the error: attempt to index? (a nil value)
this is the code i've created thus far and with the reactor connected is works.
local monitor3x1 = peripheral.wrap("monitor_1")
local reactor = peripheral.wrap("BigReactors-Reactor_0")
local conreact = 0
conreact = reactor.getConnected()
monitor3x1.clear()
monitor3x1.setCursorPos(7, 3)
monitor3x1.write("Finding reactors...")
if conreact==true then
monitor3x1.clear()
monitor3x1.setCursorPos(10, 2)
monitor3x1.write("Reactor found")
monitor3x1.setCursorPos(2, 3)
monitor3x1.write("initializing... Please wait")
monitor3x1.setCursorPos(5, 5)
monitor3x1.write("Reactor Status Program")
else
monitor3x1.clear()
monitor3x1.setCursorPos(8, 2)
monitor3x1.setTextColor(0x4000)
monitor3x1.write("WARNING!!")
monitor3x1.setTextColor(0x1)
monitor3x1.setCursorPos(4, 3)
monitor3x1.write("No reactor found")
monitor3x1.setCursorPos(1, 4)
monitor3x1.write("Please check your connection")
end
is there a way i can prevent that error message from showing ?