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

Screen flickers on update - how to stop it?

Started by xBlizzDevious, 16 February 2014 - 10:10 AM
xBlizzDevious #1
Posted 16 February 2014 - 11:10 AM
Hey guys, I've written a program to monitor and control a basic "Big Reactors" reactor and I'm quite pleased with it, however, it flickers every two seconds when the while loop runs again. Is there a way to make it not flicker?

Here's the code I've written:

Spoiler

hec = peripheral.wrap("cofh_thermalexpansion_energycell_0")
br = peripheral.wrap("BigReactors-Reactor_0")

local maxStore = 0
local curStore = 0
local thirty = 0
local ninety = 0
local rTemp = 0
local rCurStore = 0
local rFuelAmount = 0
local rFuelMax = 0
local rWasteAmount = 0
local rEProduced = 0
local rCRodL = 0

maxStore = hec.getMaxEnergyStored("")
thirty = (maxStore/100)*30
ninety = (maxStore/100)*90

while true do
    term.clear()
    term.setCursorPos(1,1)
    curStore = hec.getEnergyStored("")
    
    rTemp = br.getTemperature()
    rCurStore = br.getEnergyStored()
    rFuelAmount = br.getFuelAmount()
    rFuelMax = br.getFuelAmountMax()
    rWasteAmount = br.getWasteAmount()
    rEProduced = math.floor(br.getEnergyProducedLastTick())
    
    print("		 Energy Cell: "..curStore.." / "..maxStore.." RF")
    print("")
    print("		 Temperature: "..rTemp.." C")
    print("    Energy (Reactor): "..rCurStore.." RF")
    print("			    Fuel: "..rFuelAmount.." / "..rFuelMax.." mB")
    print("			   Waste: "..rWasteAmount.." mB")
    print("    Energy Last Tick: "..rEProduced.." RF")
    print("")
    if curStore <= thirty then
        br.setActive(true)
        print("		  Reactor is: ON")
    elseif curStore >= ninety then
        br.setActive(false)
        print("		  Reactor is: OFF")
    end
    sleep(2)
end
Bab #2
Posted 16 February 2014 - 03:36 PM
Try moving the term.clear down to between the calculations and the prints.
xBlizzDevious #3
Posted 16 February 2014 - 06:07 PM
Try moving the term.clear down to between the calculations and the prints.

Ah, perfect, thank you! Doesn't flicker at all any more!