Jump to content




Feeding a monitor with live information from Big Reactors


  • You cannot reply to this topic
5 replies to this topic

#1 Trakthor

  • Members
  • 3 posts

Posted 02 April 2014 - 09: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:

Posted Image

Any ideas on how I may improve this?

Thanks,
Trakthor.

#2 apemanzilla

  • Members
  • 1,421 posts

Posted 02 April 2014 - 10:54 PM

To the bottom of the loop, add this:
local _,y = monitor.getCursorPos()
monitor.setCursorPos(1,y)


#3 Trakthor

  • Members
  • 3 posts

Posted 03 April 2014 - 12:00 AM

View PostApemanzilla, on 02 April 2014 - 10:54 PM, said:

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.

#4 guesswhat123212

  • Members
  • 31 posts

Posted 03 April 2014 - 01: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()

#5 Trakthor

  • Members
  • 3 posts

Posted 03 April 2014 - 02:53 AM

Yes, I sorted it out after some trial and error.
Thanks anyway! :)

#6 apemanzilla

  • Members
  • 1,421 posts

Posted 03 April 2014 - 04: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users