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

i can´t run my script so i can monitor my reactor from big reactors

Started by baier, 27 January 2017 - 01:17 PM
baier #1
Posted 27 January 2017 - 02:17 PM
it just says
starttup:4: attempt to index ? (a nil value)
this is my code

while true do
	local reactor1 = peripheral.wrap("BigReactors-Reactor_0")
	local mon = peripheral.wrap("monitor_1")
	mon.clear()
	-- Begin Reactor 1
	--mon.setCursorPos(1,1)
	--mon.setTextColor(colors.white)
	--mon.write("Reactor #: ")
	--mon.setTextColor(colors.lime)
	--mon.write("1")
	mon.setCursorPos(1,2)
	mon.setTextColor(colors.white)
	mon.write("Active: ")
	mon.setTextColor(colors.lime)
	mon.write(reactor1.getActive())
	mon.setCursorPos(1,3)
	mon.setTextColor(colors.white)
	mon.write("RF/T: ") 
	mon.setTextColor(colors.lime)
	mon.write(math.floor(reactor1.getEnergyProducedLastTick()))
	mon.setCursorPos(1,4)
	mon.setTextColor(colors.white)
	mon.write("RF Stored: ")
	mon.setTextColor(colors.lime)
	mon.write(math.floor(reactor1.getEnergyStored()))
	mon.setCursorPos(1,5)
	mon.setTextColor(colors.white)
	mon.write("Casing Heat: ")
	mon.setTextColor(colors.lime)
	mon.write(math.floor(reactor1.getCasingTemperature()))
	mon.setCursorPos(1,6)
	mon.setTextColor(colors.white)
	mon.write("Fuel Heat: ")
	mon.setTextColor(colors.lime)
	mon.write(math.floor(reactor1.getFuelTemperature()))
	-- End Reactor 1
	sleep(5)
end
Edited by
Dog #2
Posted 27 January 2017 - 04:38 PM
That error means you're trying to access a table entry that doesn't exist (in this case, the table provided by wrapping the monitor). It looks like the monitor you're looking for isn't named "monitor_1". You'll want to double check the monitor name, and also make sure the modem on the monitor is turned on.

Also, I'd recommend moving your calls to peripheral.wrap() outside (above) of your loop - you only need to wrap the hardware once.
Bomb Bloke #3
Posted 28 January 2017 - 12:46 PM
Instead of peripheral.wrap("monitor_whatever"), you might use peripheral.find("monitor").
thedorkknight91 #4
Posted 30 January 2017 - 06:55 AM
it seemed to run fine for me. all i had to do was tell it what monitor and reactor to use. super silly question, im not much of a coder myself, but did you wrap the modems after getting this script?

I used the same video (or program anyways) to learn my first bit of coding, and just came back and redid a lot of playing with big reactors and computer craft. I have a couple of programs that will display more stats on a bigger monitor, or manage multiple reactors. in fack bomb bloke just helped me (thank you again incase you missed my last thanks, i really am appreciative!) with a peripheral error with the capacitor banks. if youd like to check them out ill happily share ;)/>


but i think you might have your modems on your monitor wrapped wrong, maybe your reactor too. again, i dont know much, but that's where id start looking