Jump to content




Tempermental Monitors


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

#1 andreblue

  • New Members
  • 1 posts

Posted 30 August 2015 - 06:52 PM

I have the below code which for some reason only sometimes wants to write to the monitor. I have done it with wraping and with finding and can never really reproduce the same issue each time. is there anything you see that could cause the issue?

local reactor = peripheral.find("BigReactors-Reactor")
local monitor = peripheral.wrap("monitor_1")
print(tostring(monitor))
local function percentMe(currentValue, maxValue)
    return math.floor((100*currentValue)/maxValue)
end
local status
local statusColor
term.redirect(monitor)
while true do
    local maxPower = 10000000
    local storedPower = math.floor(reactor.getEnergyStored())
    local powerPercent = percentMe(storedPower, maxPower)
   
    local maxFuel = math.floor(reactor.getFuelAmountMax())
   
    local fuelStored = math.floor(reactor.getFuelAmount())
    local fuelPercent = percentMe(fuelStored, maxFuel)
   
    local wasteStored = math.floor(reactor.getWasteAmount())
    local wastePercent = percentMe(wasteStored, maxFuel)
   
    local casingHeat = reactor.getCasingTemperature()
    local coreHeat = reactor.getFuelTemperature()
   
    local perTickGen = reactor.getEnergyProducedLastTick()
    --control our reactor
    if powerPercent > 80 then
	    reactor.setActive(false)
    else
	    reactor.setActive(true)
    end
   
    --do monitor thins
    term.clear()
    term.setBackgroundColor(colors.black)
    term.setCursorPos(1,1)
    term.setTextColor(colors.white)
    term.write("Reactor Status: ")
    term.setCursorPos(17,1)
	    if reactor.getActive() then
		    statusColor = colors.lime
		    status = "Online"
	    else
		    statusColor = colors.red
		    status = "Offline"
	    end
	   
    term.setTextColor(statusColor)
    term.write(status)
    term.setCursorPos(1,2)
    term.setBackgroundColor(colors.black)
    term.setTextColor(colors.white)
    term.write("Reactor Fuel(%): " .. tostring(fuelPercent))
    term.setCursorPos(1,3)
    term.setBackgroundColor(colors.black)
    term.setTextColor(colors.white)
    term.write("Reactor Waste(%): " .. tostring(wastePercent))
    term.setCursorPos(1,4)
    term.setBackgroundColor(colors.black)
    term.setTextColor(colors.white)
    term.write("Reactor Power: " .. tostring(storedPower) .. " RF(" .. tostring(powerPercent) .. "%)")
    term.setCursorPos(1,5)
    term.setBackgroundColor(colors.black)
    term.setTextColor(colors.white)
    term.write("Fuel Temperature(C): " .. tostring(math.floor(coreHeat)))
    term.setCursorPos(1,6)
    term.setBackgroundColor(colors.black)
    term.setTextColor(colors.white)
    term.write("Hull Temperature(C): " .. tostring(math.floor(casingHeat)))
    term.setCursorPos(1,7)
    term.setBackgroundColor(colors.black)
    term.setTextColor(colors.white)
    term.write("RF Per Tick(RF): " .. tostring(math.floor(perTickGen)))
    sleep(5)
end
   
   


#2 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 30 August 2015 - 07:57 PM

Changing the font size is a common solution to monitors misbehaving.

#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 30 August 2015 - 11:42 PM

That is to say, CC 1.74's monitors are a little buggy, and doing the above kicks them back into gear.

Note you have to change the text scale. Merely setting it to the same value it's already set to does nothing. Feel free to change it back to whatever value you actually want to use after tweaking it, though.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users