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

Feeding a monitor with live information from Big Reactors

Started by Trakthor, 02 April 2014 - 08:53 PM
Trakthor #1
Posted 02 April 2014 - 10:53 PM
Hi,

I'm currently trying to write a program which feeds the monitor with live information (such as fuel temperature) from a nuclear reactor (Big Reactors mod).

The code bit in question:

local reactor = peripheral.wrap("back")
ftemp = reactor.getFuelTemperature()

while true do
sleep(1)                                                       -- One second delay
if reactor.getFuelTemperature() > 1 then    -- if the fuel temperature is >1
  mon.write("Fuel Temp: "..ftemp)                -- monitor writes the fuel temp (partially working)
end
if reactor.getEnergyStored() < 9900000 then -- if the energy storage gets below 9900000 RF then (works)
  reactor.setActive (true)                                 -- activate the reactor (works)
end
if reactor.getEnergyStored() > 9990000 then -- if the energy storage gets above 9990000 RF then (works)
  reactor.setActive (false)                                -- shut down the reactor (works)
end
end

Now, while the energy storage part works perfectly, I seem to have some problems with the fuel temp.
The program is able to get the temperature reading, but not updating it per loop.

This is how it looks:



Any ideas on how I may improve this?

Thanks,
Trakthor.
apemanzilla #2
Posted 02 April 2014 - 11:54 PM
To the bottom of the loop, add this:

local _,y = monitor.getCursorPos()
monitor.setCursorPos(1,y)
Trakthor #3
Posted 03 April 2014 - 01:00 AM
To the bottom of the loop, add this:

local _,y = monitor.getCursorPos()
monitor.setCursorPos(1,y)

Thank you! That fixed the issue of repeating text.

You wouldn't happen to know why the value isn't updated per loop aswell?

Thanks.
guesswhat123212 #4
Posted 03 April 2014 - 02:19 AM
above your loop you are making ftemp and setting it. you are not calling it to update again afterwards, move that into your loop and it should work. also dont forget to mon.clear() and mon.setCursorPos()
Trakthor #5
Posted 03 April 2014 - 03:53 AM
Yes, I sorted it out after some trial and error.
Thanks anyway! :)/>
apemanzilla #6
Posted 03 April 2014 - 05:50 AM
You're welcome. Keep in mind that whenever you write text to a monitor or the terminal, the cursor position moves to the end of the written text, so it needed to be moved back after each iteration of the loop.