Posted 02 July 2014 - 02:54 AM
I'm playing SMP, and the server is on the same LAN as my client. I have a program that does some charting on a large advanced monitor which uses term.clear() once every tick, followed by a large number of single-character draws, and in 1.5 it worked fine - the monitor animated smoothly, there was no flicker, etc. However in CC 1.6 the monitor flickers incredibly badly, rendering the chart nearly unreadable. It appears like the draws are not all completed, so that it renders with the clear() having occurred and only a few of the writes to the screen after that having been completed before the texture is rendered.
The code running on the computer (both in 1.5 and in 1.6) is the following:
The code running on the computer (both in 1.5 and in 1.6) is the following:
historyLength = 50
sampleInterval = 0.05
drawTarget = peripheral.wrap("top")
drawTarget.setTextScale(0.5)
local x,y = drawTarget.getSize()
historyLength = x
boilers = {}
loadHistory = {}
-- Scans the network for any Railcraft boiler and adds it to the Boilers list
function getBoilers()
boilers = {}
local hosts = peripheral.getNames()
for index, hostName in pairs(hosts) do
if hostName:find("rcboilertank") == 1 then
table.insert(boilers, peripheral.wrap(hostName))
end
end
end
function getInstantaneousLoad()
local steamLoad = 0
local numTanks = 0
for index, boiler in pairs(boilers) do
local steamTank = boiler.getTankInfo("top")[2]
local steamAdjust = steamTank.capacity / 2
if (steamTank.amount > steamAdjust) then
local tankLoad = (steamTank.amount - steamAdjust) / steamAdjust
steamLoad = steamLoad + (1 - tankLoad)
numTanks = numTanks + 1
end
end
--print("Load:")
--print(steamLoad / numTanks)
return steamLoad / numTanks
end
function trackLoadHistory(newLoad)
if #loadHistory > historyLength then
table.remove(loadHistory, 1)
end
--table.insert(loadHistory, newLoad)
loadHistory[#loadHistory + 1] = newLoad
end
function drawLoadChart(target)
target.clear()
targetWidth, targetHeight = target.getSize()
for x = 1,targetWidth do
if #loadHistory >= (x) then
local maxY = math.floor(loadHistory[x] * targetHeight)
for barY = 1, maxY do
local drawColor
if (target.isColor()) then
if (barY < .2 * targetHeight) then drawColor = colors.green
elseif barY < .4 * targetHeight then drawColor = colors.lime
elseif barY < .6 * targetHeight then drawColor = colors.yellow
elseif barY < .8 * targetHeight then drawColor = colors.orange
else drawColor = colors.red
end
else
drawColor = colors.white
end
target.setBackgroundColor(drawColor)
target.setCursorPos(x, targetHeight - barY + 1)
target.write(" ")
end
end
end
local load = math.floor(loadHistory[#loadHistory] * 100)
target.setCursorPos(1, 1)
target.setBackgroundColor(colors.black)
target.write("Current steam load: "..load.."%")
end
sleep(1) -- Initialization delay for chunk loading
getBoilers()
while true do
sleep(sampleInterval)
trackLoadHistory(getInstantaneousLoad())
drawLoadChart(drawTarget)
end